Skip to content

Commit

Permalink
fix: wait for photon slot to match rpc slot in confirmTx (#1019)
Browse files Browse the repository at this point in the history
* confirmTxIndexed

* fix

---------

Co-authored-by: Swen <[email protected]>
  • Loading branch information
SwenSchaeferjohann and Swen authored Jul 23, 2024
1 parent 43bcac1 commit 6062d1d
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 15 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ jobs:
npx nx build @lightprotocol/zk-compression-cli --skip-nx-cache
# Commented for breaking changes to Photon
# - name: Run CLI tests
# run: |
# source ./scripts/devenv.sh
# npx nx test @lightprotocol/zk-compression-cli
- name: Run CLI tests
run: |
source ./scripts/devenv.sh
npx nx test @lightprotocol/zk-compression-cli
- name: Run stateless.js tests
run: |
source ./scripts/devenv.sh
npx nx test @lightprotocol/stateless.js
npx nx test @lightprotocol/stateless.js
- name: Run compressed-token tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion cli/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const LIGHT_PROVER_PROCESS_NAME = "light-prover";
export const INDEXER_PROCESS_NAME = "photon";
export const FORESTER_PROCESS_NAME = "forester";

export const PHOTON_VERSION = "0.35.0";
export const PHOTON_VERSION = "0.36.0";

export const LIGHT_PROTOCOL_PROGRAMS_DIR_ENV = "LIGHT_PROTOCOL_PROGRAMS_DIR";
export const BASE_PATH = "../../bin/";
2 changes: 1 addition & 1 deletion js/compressed-token/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"test:e2e:compress": "pnpm test-validator && vitest run tests/e2e/compress.test.ts --reporter=verbose",
"test:e2e:decompress": "pnpm test-validator && vitest run tests/e2e/decompress.test.ts --reporter=verbose",
"test:e2e:rpc-token-interop": "pnpm test-validator && vitest run tests/e2e/rpc-token-interop.test.ts --reporter=verbose",
"test:e2e:all": "pnpm test-validator && vitest run tests/e2e/create-mint.test.ts && vitest run tests/e2e/mint-to.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/decompress.test.ts && vitest run tests/e2e/register-mint.test.ts && vitest run tests/e2e/approve-and-mint-to.test.ts",
"test:e2e:all": "pnpm test-validator && vitest run tests/e2e/create-mint.test.ts && vitest run tests/e2e/mint-to.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/decompress.test.ts && vitest run tests/e2e/register-mint.test.ts && vitest run tests/e2e/approve-and-mint-to.test.ts && vitest run tests/e2e/rpc-token-interop.test.ts",
"pull-idl": "../../scripts/push-compressed-token-idl.sh",
"build": "rimraf dist && pnpm pull-idl && pnpm build:bundle",
"build:bundle": "rollup -c",
Expand Down
18 changes: 18 additions & 0 deletions js/compressed-token/src/idl/light_compressed_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -280,6 +281,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
];
Expand Down Expand Up @@ -319,6 +321,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -353,6 +356,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
];
Expand Down Expand Up @@ -392,6 +396,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -461,6 +466,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -535,6 +541,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -575,6 +582,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
];
Expand Down Expand Up @@ -701,6 +709,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -1783,6 +1792,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down Expand Up @@ -1839,6 +1849,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: true,
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
],
Expand Down Expand Up @@ -1878,6 +1889,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down Expand Up @@ -1912,6 +1924,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: true,
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
],
Expand Down Expand Up @@ -1951,6 +1964,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down Expand Up @@ -2020,6 +2034,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down Expand Up @@ -2094,6 +2109,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down Expand Up @@ -2134,6 +2150,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: true,
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
],
Expand Down Expand Up @@ -2260,6 +2277,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down
14 changes: 10 additions & 4 deletions js/compressed-token/tests/e2e/rpc-token-interop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import {
} from '@lightprotocol/stateless.js';
import { WasmFactory } from '@lightprotocol/hasher.rs';
import { createMint, mintTo, transfer } from '../../src/actions';
import {
PublicTransactionEvent,
getParsedEvents,
} from '../../../stateless.js/src';

const TEST_TOKEN_DECIMALS = 2;

Expand All @@ -24,13 +28,14 @@ describe('rpc-interop token', () => {
let mintAuthority: Keypair;

beforeAll(async () => {
const lightWasm = await WasmFactory.getInstance();
rpc = createRpc();
testRpc = await getTestRpc(lightWasm);
const lightWasm = await WasmFactory.getInstance();
payer = await newAccountWithLamports(rpc, 1e9, 256);
mintAuthority = Keypair.generate();
const mintKeypair = Keypair.generate();

testRpc = await getTestRpc(lightWasm);

mint = (
await createMint(
rpc,
Expand All @@ -45,8 +50,8 @@ describe('rpc-interop token', () => {
charlie = await newAccountWithLamports(rpc, 1e9, 256);

await mintTo(rpc, payer, mint, bob.publicKey, mintAuthority, bn(1000));
/// TODO: replace for Rpc once 'getValidityProof' in Photon is working.
await transfer(testRpc, payer, mint, bn(700), bob, charlie.publicKey);

await transfer(rpc, payer, mint, bn(700), bob, charlie.publicKey);
});

it('getCompressedTokenAccountsByOwner should match', async () => {
Expand Down Expand Up @@ -78,6 +83,7 @@ describe('rpc-interop token', () => {
charlie.publicKey,
{ mint },
);

const receiverAccountsTest =
await testRpc.getCompressedTokenAccountsByOwner(charlie.publicKey, {
mint,
Expand Down
18 changes: 18 additions & 0 deletions js/stateless.js/src/idls/light_compressed_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -280,6 +281,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
];
Expand Down Expand Up @@ -319,6 +321,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -353,6 +356,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
];
Expand Down Expand Up @@ -392,6 +396,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -461,6 +466,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -535,6 +541,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -575,6 +582,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
];
Expand Down Expand Up @@ -701,6 +709,7 @@ export type LightCompressedToken = {
isMut: false;
isSigner: false;
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
];
},
Expand Down Expand Up @@ -1783,6 +1792,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down Expand Up @@ -1839,6 +1849,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: true,
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
],
Expand Down Expand Up @@ -1878,6 +1889,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down Expand Up @@ -1912,6 +1924,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: true,
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
],
Expand Down Expand Up @@ -1951,6 +1964,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down Expand Up @@ -2020,6 +2034,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down Expand Up @@ -2094,6 +2109,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down Expand Up @@ -2134,6 +2150,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: true,
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.',
],
Expand Down Expand Up @@ -2260,6 +2277,7 @@ export const IDL: LightCompressedToken = {
isMut: false,
isSigner: false,
docs: [
'(different program) checked in light system program to derive',
'cpi_authority_pda and check that this program is the signer of the cpi.',
],
},
Expand Down
Loading

0 comments on commit 6062d1d

Please sign in to comment.