@layerzerolabs/lz-solana-sdk-v2 3.0.66 → 3.0.68-ton.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/umi.cjs +188 -14
- package/dist/umi.cjs.map +1 -1
- package/dist/umi.d.mts +88 -7
- package/dist/umi.d.ts +88 -7
- package/dist/umi.mjs +188 -15
- package/dist/umi.mjs.map +1 -1
- package/package.json +13 -10
- package/src/generated/kinobi/dvn/instructions/extendDvnConfig.ts +124 -0
- package/src/generated/kinobi/dvn/instructions/index.ts +1 -0
- package/src/generated/kinobi/executor/instructions/extendExecutorConfig.ts +124 -0
- package/src/generated/kinobi/executor/instructions/index.ts +1 -0
- package/src/generated/kinobi/pricefeed/instructions/extendPriceFeed.ts +124 -0
- package/src/generated/kinobi/pricefeed/instructions/index.ts +1 -0
- package/src/next_nonce.ts +2 -9
- package/src/utility.ts +14 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/lz-solana-sdk-v2",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.68-ton.0",
|
|
4
4
|
"license": "BUSL-1.1",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -35,15 +35,16 @@
|
|
|
35
35
|
"sync-target-idl": "mkdir -p target/idl && rsync -avc --delete ../solana/target/idl/ target/idl/",
|
|
36
36
|
"test": "anchor test --skip-build",
|
|
37
37
|
"test-endpoint": "TEST_SCOPES=endpoint anchor test --skip-build",
|
|
38
|
+
"test-extend": "yarn run ts-mocha -b -p ./tsconfig.json -t 10000000 tests/extend_account.test.ts",
|
|
38
39
|
"test-uln": "TEST_SCOPES=uln anchor test --skip-build"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@layerzerolabs/lz-corekit-solana": "^3.0.
|
|
42
|
-
"@layerzerolabs/lz-definitions": "^3.0.
|
|
43
|
-
"@layerzerolabs/lz-foundation": "^3.0.
|
|
44
|
-
"@layerzerolabs/lz-serdes": "^3.0.
|
|
45
|
-
"@layerzerolabs/lz-utilities": "^3.0.
|
|
46
|
-
"@layerzerolabs/lz-v2-utilities": "^3.0.
|
|
42
|
+
"@layerzerolabs/lz-corekit-solana": "^3.0.68-ton.0",
|
|
43
|
+
"@layerzerolabs/lz-definitions": "^3.0.68-ton.0",
|
|
44
|
+
"@layerzerolabs/lz-foundation": "^3.0.68-ton.0",
|
|
45
|
+
"@layerzerolabs/lz-serdes": "^3.0.68-ton.0",
|
|
46
|
+
"@layerzerolabs/lz-utilities": "^3.0.68-ton.0",
|
|
47
|
+
"@layerzerolabs/lz-v2-utilities": "^3.0.68-ton.0",
|
|
47
48
|
"@metaplex-foundation/beet": "^0.7.1",
|
|
48
49
|
"@metaplex-foundation/beet-solana": "^0.4.0",
|
|
49
50
|
"@metaplex-foundation/umi": "^0.9.2",
|
|
@@ -65,14 +66,15 @@
|
|
|
65
66
|
"@kinobi-so/renderers": "^0.21.3",
|
|
66
67
|
"@kinobi-so/renderers-js-umi": "^0.21.6",
|
|
67
68
|
"@layerzerolabs/layerzero-v2-solana": "^0.0.0",
|
|
68
|
-
"@layerzerolabs/tsup-config-next": "^3.0.
|
|
69
|
-
"@layerzerolabs/typescript-config-next": "^3.0.
|
|
69
|
+
"@layerzerolabs/tsup-config-next": "^3.0.68-ton.0",
|
|
70
|
+
"@layerzerolabs/typescript-config-next": "^3.0.68-ton.0",
|
|
70
71
|
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
|
|
71
72
|
"@types/bn.js": "^5.1.5",
|
|
72
73
|
"@types/chai": "^4.3.11",
|
|
73
74
|
"@types/chai-as-promised": "^7.1.0",
|
|
74
75
|
"@types/mocha": "^10.0.6",
|
|
75
76
|
"@types/node": "^20.10.5",
|
|
77
|
+
"axios": "^1.6.2",
|
|
76
78
|
"chai": "^4.3.10",
|
|
77
79
|
"chai-as-promised": "^7.1.1",
|
|
78
80
|
"kinobi": "^0.21.4",
|
|
@@ -81,7 +83,8 @@
|
|
|
81
83
|
"ts-mocha": "^10.0.0",
|
|
82
84
|
"ts-node": "^10.9.1",
|
|
83
85
|
"tsup": "^8.3.5",
|
|
84
|
-
"typescript": "~5.2.2"
|
|
86
|
+
"typescript": "~5.2.2",
|
|
87
|
+
"zx": "^8.1.3"
|
|
85
88
|
},
|
|
86
89
|
"publishConfig": {
|
|
87
90
|
"access": "public"
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the kinobi library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun kinobi to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/kinobi-so/kinobi
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
Context,
|
|
11
|
+
Pda,
|
|
12
|
+
PublicKey,
|
|
13
|
+
Signer,
|
|
14
|
+
TransactionBuilder,
|
|
15
|
+
transactionBuilder,
|
|
16
|
+
} from '@metaplex-foundation/umi';
|
|
17
|
+
import {
|
|
18
|
+
Serializer,
|
|
19
|
+
bytes,
|
|
20
|
+
mapSerializer,
|
|
21
|
+
struct,
|
|
22
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
23
|
+
import {
|
|
24
|
+
ResolvedAccount,
|
|
25
|
+
ResolvedAccountsWithIndices,
|
|
26
|
+
getAccountMetasAndSigners,
|
|
27
|
+
} from '../shared';
|
|
28
|
+
|
|
29
|
+
// Accounts.
|
|
30
|
+
export type ExtendDvnConfigInstructionAccounts = {
|
|
31
|
+
admin: Signer;
|
|
32
|
+
config: PublicKey | Pda;
|
|
33
|
+
systemProgram?: PublicKey | Pda;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Data.
|
|
37
|
+
export type ExtendDvnConfigInstructionData = { discriminator: Uint8Array };
|
|
38
|
+
|
|
39
|
+
export type ExtendDvnConfigInstructionDataArgs = {};
|
|
40
|
+
|
|
41
|
+
export function getExtendDvnConfigInstructionDataSerializer(): Serializer<
|
|
42
|
+
ExtendDvnConfigInstructionDataArgs,
|
|
43
|
+
ExtendDvnConfigInstructionData
|
|
44
|
+
> {
|
|
45
|
+
return mapSerializer<
|
|
46
|
+
ExtendDvnConfigInstructionDataArgs,
|
|
47
|
+
any,
|
|
48
|
+
ExtendDvnConfigInstructionData
|
|
49
|
+
>(
|
|
50
|
+
struct<ExtendDvnConfigInstructionData>(
|
|
51
|
+
[['discriminator', bytes({ size: 8 })]],
|
|
52
|
+
{ description: 'ExtendDvnConfigInstructionData' }
|
|
53
|
+
),
|
|
54
|
+
(value) => ({
|
|
55
|
+
...value,
|
|
56
|
+
discriminator: new Uint8Array([183, 248, 24, 49, 110, 229, 169, 66]),
|
|
57
|
+
})
|
|
58
|
+
) as Serializer<
|
|
59
|
+
ExtendDvnConfigInstructionDataArgs,
|
|
60
|
+
ExtendDvnConfigInstructionData
|
|
61
|
+
>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Instruction.
|
|
65
|
+
export function extendDvnConfig(
|
|
66
|
+
context: Pick<Context, 'programs'>,
|
|
67
|
+
input: ExtendDvnConfigInstructionAccounts
|
|
68
|
+
): TransactionBuilder {
|
|
69
|
+
// Program ID.
|
|
70
|
+
const programId = context.programs.getPublicKey(
|
|
71
|
+
'dvn',
|
|
72
|
+
'HtEYV4xB4wvsj5fgTkcfuChYpvGYzgzwvNhgDZQNh7wW'
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Accounts.
|
|
76
|
+
const resolvedAccounts = {
|
|
77
|
+
admin: {
|
|
78
|
+
index: 0,
|
|
79
|
+
isWritable: true as boolean,
|
|
80
|
+
value: input.admin ?? null,
|
|
81
|
+
},
|
|
82
|
+
config: {
|
|
83
|
+
index: 1,
|
|
84
|
+
isWritable: true as boolean,
|
|
85
|
+
value: input.config ?? null,
|
|
86
|
+
},
|
|
87
|
+
systemProgram: {
|
|
88
|
+
index: 2,
|
|
89
|
+
isWritable: false as boolean,
|
|
90
|
+
value: input.systemProgram ?? null,
|
|
91
|
+
},
|
|
92
|
+
} satisfies ResolvedAccountsWithIndices;
|
|
93
|
+
|
|
94
|
+
// Default values.
|
|
95
|
+
if (!resolvedAccounts.systemProgram.value) {
|
|
96
|
+
resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
|
|
97
|
+
'splSystem',
|
|
98
|
+
'11111111111111111111111111111111'
|
|
99
|
+
);
|
|
100
|
+
resolvedAccounts.systemProgram.isWritable = false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Accounts in order.
|
|
104
|
+
const orderedAccounts: ResolvedAccount[] = Object.values(
|
|
105
|
+
resolvedAccounts
|
|
106
|
+
).sort((a, b) => a.index - b.index);
|
|
107
|
+
|
|
108
|
+
// Keys and Signers.
|
|
109
|
+
const [keys, signers] = getAccountMetasAndSigners(
|
|
110
|
+
orderedAccounts,
|
|
111
|
+
'programId',
|
|
112
|
+
programId
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Data.
|
|
116
|
+
const data = getExtendDvnConfigInstructionDataSerializer().serialize({});
|
|
117
|
+
|
|
118
|
+
// Bytes Created On Chain.
|
|
119
|
+
const bytesCreatedOnChain = 0;
|
|
120
|
+
|
|
121
|
+
return transactionBuilder([
|
|
122
|
+
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the kinobi library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun kinobi to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/kinobi-so/kinobi
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
Context,
|
|
11
|
+
Pda,
|
|
12
|
+
PublicKey,
|
|
13
|
+
Signer,
|
|
14
|
+
TransactionBuilder,
|
|
15
|
+
transactionBuilder,
|
|
16
|
+
} from '@metaplex-foundation/umi';
|
|
17
|
+
import {
|
|
18
|
+
Serializer,
|
|
19
|
+
bytes,
|
|
20
|
+
mapSerializer,
|
|
21
|
+
struct,
|
|
22
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
23
|
+
import {
|
|
24
|
+
ResolvedAccount,
|
|
25
|
+
ResolvedAccountsWithIndices,
|
|
26
|
+
getAccountMetasAndSigners,
|
|
27
|
+
} from '../shared';
|
|
28
|
+
|
|
29
|
+
// Accounts.
|
|
30
|
+
export type ExtendExecutorConfigInstructionAccounts = {
|
|
31
|
+
admin: Signer;
|
|
32
|
+
config: PublicKey | Pda;
|
|
33
|
+
systemProgram?: PublicKey | Pda;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Data.
|
|
37
|
+
export type ExtendExecutorConfigInstructionData = { discriminator: Uint8Array };
|
|
38
|
+
|
|
39
|
+
export type ExtendExecutorConfigInstructionDataArgs = {};
|
|
40
|
+
|
|
41
|
+
export function getExtendExecutorConfigInstructionDataSerializer(): Serializer<
|
|
42
|
+
ExtendExecutorConfigInstructionDataArgs,
|
|
43
|
+
ExtendExecutorConfigInstructionData
|
|
44
|
+
> {
|
|
45
|
+
return mapSerializer<
|
|
46
|
+
ExtendExecutorConfigInstructionDataArgs,
|
|
47
|
+
any,
|
|
48
|
+
ExtendExecutorConfigInstructionData
|
|
49
|
+
>(
|
|
50
|
+
struct<ExtendExecutorConfigInstructionData>(
|
|
51
|
+
[['discriminator', bytes({ size: 8 })]],
|
|
52
|
+
{ description: 'ExtendExecutorConfigInstructionData' }
|
|
53
|
+
),
|
|
54
|
+
(value) => ({
|
|
55
|
+
...value,
|
|
56
|
+
discriminator: new Uint8Array([238, 223, 196, 220, 61, 71, 72, 85]),
|
|
57
|
+
})
|
|
58
|
+
) as Serializer<
|
|
59
|
+
ExtendExecutorConfigInstructionDataArgs,
|
|
60
|
+
ExtendExecutorConfigInstructionData
|
|
61
|
+
>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Instruction.
|
|
65
|
+
export function extendExecutorConfig(
|
|
66
|
+
context: Pick<Context, 'programs'>,
|
|
67
|
+
input: ExtendExecutorConfigInstructionAccounts
|
|
68
|
+
): TransactionBuilder {
|
|
69
|
+
// Program ID.
|
|
70
|
+
const programId = context.programs.getPublicKey(
|
|
71
|
+
'executor',
|
|
72
|
+
'6doghB248px58JSSwG4qejQ46kFMW4AMj7vzJnWZHNZn'
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Accounts.
|
|
76
|
+
const resolvedAccounts = {
|
|
77
|
+
admin: {
|
|
78
|
+
index: 0,
|
|
79
|
+
isWritable: true as boolean,
|
|
80
|
+
value: input.admin ?? null,
|
|
81
|
+
},
|
|
82
|
+
config: {
|
|
83
|
+
index: 1,
|
|
84
|
+
isWritable: true as boolean,
|
|
85
|
+
value: input.config ?? null,
|
|
86
|
+
},
|
|
87
|
+
systemProgram: {
|
|
88
|
+
index: 2,
|
|
89
|
+
isWritable: false as boolean,
|
|
90
|
+
value: input.systemProgram ?? null,
|
|
91
|
+
},
|
|
92
|
+
} satisfies ResolvedAccountsWithIndices;
|
|
93
|
+
|
|
94
|
+
// Default values.
|
|
95
|
+
if (!resolvedAccounts.systemProgram.value) {
|
|
96
|
+
resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
|
|
97
|
+
'splSystem',
|
|
98
|
+
'11111111111111111111111111111111'
|
|
99
|
+
);
|
|
100
|
+
resolvedAccounts.systemProgram.isWritable = false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Accounts in order.
|
|
104
|
+
const orderedAccounts: ResolvedAccount[] = Object.values(
|
|
105
|
+
resolvedAccounts
|
|
106
|
+
).sort((a, b) => a.index - b.index);
|
|
107
|
+
|
|
108
|
+
// Keys and Signers.
|
|
109
|
+
const [keys, signers] = getAccountMetasAndSigners(
|
|
110
|
+
orderedAccounts,
|
|
111
|
+
'programId',
|
|
112
|
+
programId
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Data.
|
|
116
|
+
const data = getExtendExecutorConfigInstructionDataSerializer().serialize({});
|
|
117
|
+
|
|
118
|
+
// Bytes Created On Chain.
|
|
119
|
+
const bytesCreatedOnChain = 0;
|
|
120
|
+
|
|
121
|
+
return transactionBuilder([
|
|
122
|
+
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
@@ -10,6 +10,7 @@ export * from './adminSetConfig';
|
|
|
10
10
|
export * from './compose';
|
|
11
11
|
export * from './executable';
|
|
12
12
|
export * from './execute';
|
|
13
|
+
export * from './extendExecutorConfig';
|
|
13
14
|
export * from './initExecutor';
|
|
14
15
|
export * from './nativeDrop';
|
|
15
16
|
export * from './ownerSetConfig';
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the kinobi library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun kinobi to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/kinobi-so/kinobi
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
Context,
|
|
11
|
+
Pda,
|
|
12
|
+
PublicKey,
|
|
13
|
+
Signer,
|
|
14
|
+
TransactionBuilder,
|
|
15
|
+
transactionBuilder,
|
|
16
|
+
} from '@metaplex-foundation/umi';
|
|
17
|
+
import {
|
|
18
|
+
Serializer,
|
|
19
|
+
bytes,
|
|
20
|
+
mapSerializer,
|
|
21
|
+
struct,
|
|
22
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
23
|
+
import {
|
|
24
|
+
ResolvedAccount,
|
|
25
|
+
ResolvedAccountsWithIndices,
|
|
26
|
+
getAccountMetasAndSigners,
|
|
27
|
+
} from '../shared';
|
|
28
|
+
|
|
29
|
+
// Accounts.
|
|
30
|
+
export type ExtendPriceFeedInstructionAccounts = {
|
|
31
|
+
admin: Signer;
|
|
32
|
+
priceFeed: PublicKey | Pda;
|
|
33
|
+
systemProgram?: PublicKey | Pda;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Data.
|
|
37
|
+
export type ExtendPriceFeedInstructionData = { discriminator: Uint8Array };
|
|
38
|
+
|
|
39
|
+
export type ExtendPriceFeedInstructionDataArgs = {};
|
|
40
|
+
|
|
41
|
+
export function getExtendPriceFeedInstructionDataSerializer(): Serializer<
|
|
42
|
+
ExtendPriceFeedInstructionDataArgs,
|
|
43
|
+
ExtendPriceFeedInstructionData
|
|
44
|
+
> {
|
|
45
|
+
return mapSerializer<
|
|
46
|
+
ExtendPriceFeedInstructionDataArgs,
|
|
47
|
+
any,
|
|
48
|
+
ExtendPriceFeedInstructionData
|
|
49
|
+
>(
|
|
50
|
+
struct<ExtendPriceFeedInstructionData>(
|
|
51
|
+
[['discriminator', bytes({ size: 8 })]],
|
|
52
|
+
{ description: 'ExtendPriceFeedInstructionData' }
|
|
53
|
+
),
|
|
54
|
+
(value) => ({
|
|
55
|
+
...value,
|
|
56
|
+
discriminator: new Uint8Array([16, 95, 1, 5, 220, 54, 15, 80]),
|
|
57
|
+
})
|
|
58
|
+
) as Serializer<
|
|
59
|
+
ExtendPriceFeedInstructionDataArgs,
|
|
60
|
+
ExtendPriceFeedInstructionData
|
|
61
|
+
>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Instruction.
|
|
65
|
+
export function extendPriceFeed(
|
|
66
|
+
context: Pick<Context, 'programs'>,
|
|
67
|
+
input: ExtendPriceFeedInstructionAccounts
|
|
68
|
+
): TransactionBuilder {
|
|
69
|
+
// Program ID.
|
|
70
|
+
const programId = context.programs.getPublicKey(
|
|
71
|
+
'pricefeed',
|
|
72
|
+
'8ahPGPjEbpgGaZx2NV1iG5Shj7TDwvsjkEDcGWjt94TP'
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Accounts.
|
|
76
|
+
const resolvedAccounts = {
|
|
77
|
+
admin: {
|
|
78
|
+
index: 0,
|
|
79
|
+
isWritable: true as boolean,
|
|
80
|
+
value: input.admin ?? null,
|
|
81
|
+
},
|
|
82
|
+
priceFeed: {
|
|
83
|
+
index: 1,
|
|
84
|
+
isWritable: true as boolean,
|
|
85
|
+
value: input.priceFeed ?? null,
|
|
86
|
+
},
|
|
87
|
+
systemProgram: {
|
|
88
|
+
index: 2,
|
|
89
|
+
isWritable: false as boolean,
|
|
90
|
+
value: input.systemProgram ?? null,
|
|
91
|
+
},
|
|
92
|
+
} satisfies ResolvedAccountsWithIndices;
|
|
93
|
+
|
|
94
|
+
// Default values.
|
|
95
|
+
if (!resolvedAccounts.systemProgram.value) {
|
|
96
|
+
resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
|
|
97
|
+
'splSystem',
|
|
98
|
+
'11111111111111111111111111111111'
|
|
99
|
+
);
|
|
100
|
+
resolvedAccounts.systemProgram.isWritable = false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Accounts in order.
|
|
104
|
+
const orderedAccounts: ResolvedAccount[] = Object.values(
|
|
105
|
+
resolvedAccounts
|
|
106
|
+
).sort((a, b) => a.index - b.index);
|
|
107
|
+
|
|
108
|
+
// Keys and Signers.
|
|
109
|
+
const [keys, signers] = getAccountMetasAndSigners(
|
|
110
|
+
orderedAccounts,
|
|
111
|
+
'programId',
|
|
112
|
+
programId
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Data.
|
|
116
|
+
const data = getExtendPriceFeedInstructionDataSerializer().serialize({});
|
|
117
|
+
|
|
118
|
+
// Bytes Created On Chain.
|
|
119
|
+
const bytesCreatedOnChain = 0;
|
|
120
|
+
|
|
121
|
+
return transactionBuilder([
|
|
122
|
+
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
|
|
123
|
+
]);
|
|
124
|
+
}
|
package/src/next_nonce.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { arrayify } from '@layerzerolabs/lz-utilities'
|
|
|
16
16
|
import { Packet, addressToBytes32 } from '@layerzerolabs/lz-v2-utilities'
|
|
17
17
|
|
|
18
18
|
import { EDDSA } from './pda'
|
|
19
|
-
import { instructionDiscriminator, simulateWeb3JsTransaction } from './utility'
|
|
19
|
+
import { instructionDiscriminator, simulateWeb3JsTransaction, toWeb3Connection } from './utility'
|
|
20
20
|
|
|
21
21
|
// Data.
|
|
22
22
|
export interface NextNonceInstructionData {
|
|
@@ -61,14 +61,7 @@ export async function nextNonce(
|
|
|
61
61
|
): Promise<bigint> {
|
|
62
62
|
const { sender: sender_, srcEid, receiver: receiver_ } = packet
|
|
63
63
|
const receiver = new web3.PublicKey(addressToBytes32(receiver_))
|
|
64
|
-
|
|
65
|
-
if (rpc instanceof web3.Connection) {
|
|
66
|
-
connection = rpc
|
|
67
|
-
} else if ('connection' in rpc && rpc.connection instanceof web3.Connection) {
|
|
68
|
-
;({ connection } = rpc)
|
|
69
|
-
} else {
|
|
70
|
-
throw new Error('Invalid connection')
|
|
71
|
-
}
|
|
64
|
+
const connection = toWeb3Connection(rpc)
|
|
72
65
|
const receiverInfo = await connection.getAccountInfo(receiver)
|
|
73
66
|
if (receiverInfo === null) {
|
|
74
67
|
throw new Error(`Receiver account not found: ${receiver.toBase58()}`)
|
package/src/utility.ts
CHANGED
|
@@ -222,7 +222,7 @@ export async function extractWorkerFeePaidEventByTxHash(
|
|
|
222
222
|
* @returns {Promise<E[] | null>} A promise that resolves to an array of events or null if not found.
|
|
223
223
|
*/
|
|
224
224
|
export async function extractEventFromTransactionSignature<From, To extends From = From>(
|
|
225
|
-
|
|
225
|
+
rpc: web3.Connection | RpcInterface,
|
|
226
226
|
_program: PublicKey | web3.PublicKey,
|
|
227
227
|
signature: web3.TransactionSignature | web3.ParsedTransactionWithMeta | null,
|
|
228
228
|
serializer: Serializer<From, To>,
|
|
@@ -237,13 +237,8 @@ export async function extractEventFromTransactionSignature<From, To extends From
|
|
|
237
237
|
}
|
|
238
238
|
let tx: web3.ParsedTransactionWithMeta | null
|
|
239
239
|
if (typeof signature === 'string') {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
} else if ('connection' in connection && connection.connection instanceof web3.Connection) {
|
|
243
|
-
tx = await connection.connection.getParsedTransaction(signature, commitment)
|
|
244
|
-
} else {
|
|
245
|
-
throw new Error('Invalid connection')
|
|
246
|
-
}
|
|
240
|
+
const connection = toWeb3Connection(rpc)
|
|
241
|
+
tx = await connection.getParsedTransaction(signature, commitment)
|
|
247
242
|
} else {
|
|
248
243
|
tx = signature
|
|
249
244
|
}
|
|
@@ -575,12 +570,8 @@ export async function simulateWeb3JsTransaction<From, To extends From = From>(
|
|
|
575
570
|
let connection: web3.Connection
|
|
576
571
|
if (typeof _connection === 'string') {
|
|
577
572
|
connection = new web3.Connection(_connection, commitment)
|
|
578
|
-
} else if (_connection instanceof web3.Connection) {
|
|
579
|
-
connection = _connection
|
|
580
|
-
} else if ('connection' in _connection && _connection.connection instanceof web3.Connection) {
|
|
581
|
-
;({ connection } = _connection)
|
|
582
573
|
} else {
|
|
583
|
-
|
|
574
|
+
connection = toWeb3Connection(_connection)
|
|
584
575
|
}
|
|
585
576
|
|
|
586
577
|
let instructions: web3.TransactionInstruction[]
|
|
@@ -636,3 +627,13 @@ export async function simulateWeb3JsTransaction<From, To extends From = From>(
|
|
|
636
627
|
return serializer.deserialize(resp, 0)[0]
|
|
637
628
|
}
|
|
638
629
|
}
|
|
630
|
+
|
|
631
|
+
export function toWeb3Connection(rpc: RpcInterface | web3.Connection): web3.Connection {
|
|
632
|
+
if (rpc instanceof web3.Connection) {
|
|
633
|
+
return rpc
|
|
634
|
+
} else if ('connection' in rpc && rpc.connection instanceof web3.Connection) {
|
|
635
|
+
return rpc.connection
|
|
636
|
+
} else {
|
|
637
|
+
throw new Error('Invalid connection')
|
|
638
|
+
}
|
|
639
|
+
}
|