@layerzerolabs/oft-v2-solana-sdk 3.0.46 → 3.0.48
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 +20 -0
- package/deployments/solana-sandbox-local/{TokenOneOFT.json → 302/TokenOneOFT.json} +5 -4
- package/deployments/solana-sandbox-local/{TokenThreeOFT.json → 302/TokenThreeOFT.json} +5 -4
- package/deployments/solana-sandbox-local/{TokenTwoOFTAdapter.json → 302/TokenTwoOFTAdapter.json} +5 -4
- package/deployments/solana-testnet/202/TokenOneOFT.json +16 -0
- package/dist/index.cjs +2101 -266
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1349 -269
- package/dist/index.d.ts +1349 -269
- package/dist/index.mjs +2099 -260
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -9
- package/src/consts.ts +5 -0
- package/src/generated/{accounts → oft202/accounts}/lzReceiveTypesAccounts.ts +1 -2
- package/src/generated/{accounts → oft202/accounts}/oFTStore.ts +1 -2
- package/src/generated/oft202/accounts/peerConfig.ts +178 -0
- package/src/generated/oft202/instructions/index.ts +18 -0
- package/src/generated/{instructions → oft202/instructions}/initOft.ts +1 -2
- package/src/generated/{instructions → oft202/instructions}/lzReceive.ts +1 -2
- package/src/generated/{instructions → oft202/instructions}/lzReceiveTypes.ts +1 -2
- package/src/generated/{instructions → oft202/instructions}/quoteOft.ts +1 -2
- package/src/generated/oft202/instructions/quoteSend.ts +149 -0
- package/src/generated/oft202/instructions/send.ts +193 -0
- package/src/generated/{instructions → oft202/instructions}/setOftConfig.ts +1 -2
- package/src/generated/{instructions → oft202/instructions}/setPause.ts +1 -2
- package/src/generated/{instructions → oft202/instructions}/setPeerConfig.ts +1 -2
- package/src/generated/{instructions → oft202/instructions}/withdrawFee.ts +1 -2
- package/src/generated/{programs → oft202/programs}/oft.ts +2 -2
- package/src/generated/oft202/types/composeParams.ts +35 -0
- package/src/generated/oft202/types/index.ts +22 -0
- package/src/generated/oft202/types/peerConfigParam.ts +143 -0
- package/src/generated/oft302/accounts/index.ts +11 -0
- package/src/generated/oft302/accounts/lzReceiveTypesAccounts.ts +167 -0
- package/src/generated/oft302/accounts/oFTStore.ts +198 -0
- package/src/generated/{accounts → oft302/accounts}/peerConfig.ts +1 -2
- package/src/generated/oft302/errors/index.ts +9 -0
- package/src/generated/oft302/errors/oft.ts +159 -0
- package/src/generated/oft302/index.ts +14 -0
- package/src/generated/oft302/instructions/initOft.ts +179 -0
- package/src/generated/oft302/instructions/lzReceive.ts +203 -0
- package/src/generated/oft302/instructions/lzReceiveTypes.ts +124 -0
- package/src/generated/{instructions → oft302/instructions}/oftVersion.ts +1 -2
- package/src/generated/oft302/instructions/quoteOft.ts +144 -0
- package/src/generated/{instructions → oft302/instructions}/quoteSend.ts +1 -2
- package/src/generated/{instructions → oft302/instructions}/send.ts +1 -2
- package/src/generated/oft302/instructions/setOftConfig.ts +124 -0
- package/src/generated/oft302/instructions/setPause.ts +119 -0
- package/src/generated/oft302/instructions/setPeerConfig.ts +148 -0
- package/src/generated/oft302/instructions/withdrawFee.ts +151 -0
- package/src/generated/oft302/programs/index.ts +9 -0
- package/src/generated/oft302/programs/oft.ts +47 -0
- package/src/generated/oft302/shared/index.ts +117 -0
- package/src/generated/oft302/types/enforcedOptions.ts +31 -0
- package/src/generated/oft302/types/lzAccount.ts +35 -0
- package/src/generated/oft302/types/lzReceiveParams.ts +50 -0
- package/src/generated/oft302/types/messagingFee.ts +29 -0
- package/src/generated/oft302/types/oFTFeeDetail.ts +34 -0
- package/src/generated/oft302/types/oFTLimits.ts +26 -0
- package/src/generated/oft302/types/oFTReceipt.ts +29 -0
- package/src/generated/oft302/types/oFTType.ts +23 -0
- package/src/generated/oft302/types/quoteOFTResult.ts +50 -0
- package/src/generated/oft302/types/rateLimitParams.ts +38 -0
- package/src/generated/oft302/types/rateLimiter.ts +38 -0
- package/src/generated/oft302/types/setOFTConfigParams.ts +124 -0
- package/src/index.ts +5 -46
- package/src/oft202.ts +618 -0
- package/src/{oft.ts → oft302.ts} +54 -55
- package/src/pda.ts +34 -0
- package/src/types.ts +40 -0
- /package/src/generated/{accounts → oft202/accounts}/index.ts +0 -0
- /package/src/generated/{errors → oft202/errors}/index.ts +0 -0
- /package/src/generated/{errors → oft202/errors}/oft.ts +0 -0
- /package/src/generated/{index.ts → oft202/index.ts} +0 -0
- /package/src/generated/{programs → oft202/programs}/index.ts +0 -0
- /package/src/generated/{shared → oft202/shared}/index.ts +0 -0
- /package/src/generated/{types → oft202/types}/enforcedOptions.ts +0 -0
- /package/src/generated/{types → oft202/types}/lzAccount.ts +0 -0
- /package/src/generated/{types → oft202/types}/lzReceiveParams.ts +0 -0
- /package/src/generated/{types → oft202/types}/messagingFee.ts +0 -0
- /package/src/generated/{types → oft202/types}/oFTFeeDetail.ts +0 -0
- /package/src/generated/{types → oft202/types}/oFTLimits.ts +0 -0
- /package/src/generated/{types → oft202/types}/oFTReceipt.ts +0 -0
- /package/src/generated/{types → oft202/types}/oFTType.ts +0 -0
- /package/src/generated/{types → oft202/types}/quoteOFTResult.ts +0 -0
- /package/src/generated/{types → oft202/types}/rateLimitParams.ts +0 -0
- /package/src/generated/{types → oft202/types}/rateLimiter.ts +0 -0
- /package/src/generated/{types → oft202/types}/setOFTConfigParams.ts +0 -0
- /package/src/generated/{instructions → oft302/instructions}/index.ts +0 -0
- /package/src/generated/{types → oft302/types}/index.ts +0 -0
- /package/src/generated/{types → oft302/types}/peerConfigParam.ts +0 -0
- /package/src/generated/{types → oft302/types}/version.ts +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
bool,
|
|
20
|
+
bytes,
|
|
21
|
+
mapSerializer,
|
|
22
|
+
struct,
|
|
23
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
24
|
+
import {
|
|
25
|
+
ResolvedAccount,
|
|
26
|
+
ResolvedAccountsWithIndices,
|
|
27
|
+
getAccountMetasAndSigners,
|
|
28
|
+
} from '../shared';
|
|
29
|
+
|
|
30
|
+
// Accounts.
|
|
31
|
+
export type SetPauseInstructionAccounts = {
|
|
32
|
+
/** pauser or unpauser */
|
|
33
|
+
signer: Signer;
|
|
34
|
+
oftStore: PublicKey | Pda;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Data.
|
|
38
|
+
export type SetPauseInstructionData = {
|
|
39
|
+
discriminator: Uint8Array;
|
|
40
|
+
paused: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type SetPauseInstructionDataArgs = { paused: boolean };
|
|
44
|
+
|
|
45
|
+
export function getSetPauseInstructionDataSerializer(): Serializer<
|
|
46
|
+
SetPauseInstructionDataArgs,
|
|
47
|
+
SetPauseInstructionData
|
|
48
|
+
> {
|
|
49
|
+
return mapSerializer<
|
|
50
|
+
SetPauseInstructionDataArgs,
|
|
51
|
+
any,
|
|
52
|
+
SetPauseInstructionData
|
|
53
|
+
>(
|
|
54
|
+
struct<SetPauseInstructionData>(
|
|
55
|
+
[
|
|
56
|
+
['discriminator', bytes({ size: 8 })],
|
|
57
|
+
['paused', bool()],
|
|
58
|
+
],
|
|
59
|
+
{ description: 'SetPauseInstructionData' }
|
|
60
|
+
),
|
|
61
|
+
(value) => ({
|
|
62
|
+
...value,
|
|
63
|
+
discriminator: new Uint8Array([63, 32, 154, 2, 56, 103, 79, 45]),
|
|
64
|
+
})
|
|
65
|
+
) as Serializer<SetPauseInstructionDataArgs, SetPauseInstructionData>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Args.
|
|
69
|
+
export type SetPauseInstructionArgs = SetPauseInstructionDataArgs;
|
|
70
|
+
|
|
71
|
+
// Instruction.
|
|
72
|
+
export function setPause(
|
|
73
|
+
context: Pick<Context, 'programs'>,
|
|
74
|
+
input: SetPauseInstructionAccounts & SetPauseInstructionArgs
|
|
75
|
+
): TransactionBuilder {
|
|
76
|
+
// Program ID.
|
|
77
|
+
const programId = context.programs.getPublicKey('oft', '');
|
|
78
|
+
|
|
79
|
+
// Accounts.
|
|
80
|
+
const resolvedAccounts = {
|
|
81
|
+
signer: {
|
|
82
|
+
index: 0,
|
|
83
|
+
isWritable: false as boolean,
|
|
84
|
+
value: input.signer ?? null,
|
|
85
|
+
},
|
|
86
|
+
oftStore: {
|
|
87
|
+
index: 1,
|
|
88
|
+
isWritable: true as boolean,
|
|
89
|
+
value: input.oftStore ?? null,
|
|
90
|
+
},
|
|
91
|
+
} satisfies ResolvedAccountsWithIndices;
|
|
92
|
+
|
|
93
|
+
// Arguments.
|
|
94
|
+
const resolvedArgs: SetPauseInstructionArgs = { ...input };
|
|
95
|
+
|
|
96
|
+
// Accounts in order.
|
|
97
|
+
const orderedAccounts: ResolvedAccount[] = Object.values(
|
|
98
|
+
resolvedAccounts
|
|
99
|
+
).sort((a, b) => a.index - b.index);
|
|
100
|
+
|
|
101
|
+
// Keys and Signers.
|
|
102
|
+
const [keys, signers] = getAccountMetasAndSigners(
|
|
103
|
+
orderedAccounts,
|
|
104
|
+
'programId',
|
|
105
|
+
programId
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// Data.
|
|
109
|
+
const data = getSetPauseInstructionDataSerializer().serialize(
|
|
110
|
+
resolvedArgs as SetPauseInstructionDataArgs
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// Bytes Created On Chain.
|
|
114
|
+
const bytesCreatedOnChain = 0;
|
|
115
|
+
|
|
116
|
+
return transactionBuilder([
|
|
117
|
+
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
u32,
|
|
23
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
24
|
+
import {
|
|
25
|
+
ResolvedAccount,
|
|
26
|
+
ResolvedAccountsWithIndices,
|
|
27
|
+
getAccountMetasAndSigners,
|
|
28
|
+
} from '../shared';
|
|
29
|
+
import {
|
|
30
|
+
PeerConfigParam,
|
|
31
|
+
PeerConfigParamArgs,
|
|
32
|
+
getPeerConfigParamSerializer,
|
|
33
|
+
} from '../types';
|
|
34
|
+
|
|
35
|
+
// Accounts.
|
|
36
|
+
export type SetPeerConfigInstructionAccounts = {
|
|
37
|
+
admin: Signer;
|
|
38
|
+
peer: PublicKey | Pda;
|
|
39
|
+
oftStore: PublicKey | Pda;
|
|
40
|
+
systemProgram?: PublicKey | Pda;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Data.
|
|
44
|
+
export type SetPeerConfigInstructionData = {
|
|
45
|
+
discriminator: Uint8Array;
|
|
46
|
+
remoteEid: number;
|
|
47
|
+
config: PeerConfigParam;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type SetPeerConfigInstructionDataArgs = {
|
|
51
|
+
remoteEid: number;
|
|
52
|
+
config: PeerConfigParamArgs;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export function getSetPeerConfigInstructionDataSerializer(): Serializer<
|
|
56
|
+
SetPeerConfigInstructionDataArgs,
|
|
57
|
+
SetPeerConfigInstructionData
|
|
58
|
+
> {
|
|
59
|
+
return mapSerializer<
|
|
60
|
+
SetPeerConfigInstructionDataArgs,
|
|
61
|
+
any,
|
|
62
|
+
SetPeerConfigInstructionData
|
|
63
|
+
>(
|
|
64
|
+
struct<SetPeerConfigInstructionData>(
|
|
65
|
+
[
|
|
66
|
+
['discriminator', bytes({ size: 8 })],
|
|
67
|
+
['remoteEid', u32()],
|
|
68
|
+
['config', getPeerConfigParamSerializer()],
|
|
69
|
+
],
|
|
70
|
+
{ description: 'SetPeerConfigInstructionData' }
|
|
71
|
+
),
|
|
72
|
+
(value) => ({
|
|
73
|
+
...value,
|
|
74
|
+
discriminator: new Uint8Array([79, 187, 168, 57, 139, 140, 93, 47]),
|
|
75
|
+
})
|
|
76
|
+
) as Serializer<
|
|
77
|
+
SetPeerConfigInstructionDataArgs,
|
|
78
|
+
SetPeerConfigInstructionData
|
|
79
|
+
>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Args.
|
|
83
|
+
export type SetPeerConfigInstructionArgs = SetPeerConfigInstructionDataArgs;
|
|
84
|
+
|
|
85
|
+
// Instruction.
|
|
86
|
+
export function setPeerConfig(
|
|
87
|
+
context: Pick<Context, 'programs'>,
|
|
88
|
+
input: SetPeerConfigInstructionAccounts & SetPeerConfigInstructionArgs
|
|
89
|
+
): TransactionBuilder {
|
|
90
|
+
// Program ID.
|
|
91
|
+
const programId = context.programs.getPublicKey('oft', '');
|
|
92
|
+
|
|
93
|
+
// Accounts.
|
|
94
|
+
const resolvedAccounts = {
|
|
95
|
+
admin: {
|
|
96
|
+
index: 0,
|
|
97
|
+
isWritable: true as boolean,
|
|
98
|
+
value: input.admin ?? null,
|
|
99
|
+
},
|
|
100
|
+
peer: { index: 1, isWritable: true as boolean, value: input.peer ?? null },
|
|
101
|
+
oftStore: {
|
|
102
|
+
index: 2,
|
|
103
|
+
isWritable: false as boolean,
|
|
104
|
+
value: input.oftStore ?? null,
|
|
105
|
+
},
|
|
106
|
+
systemProgram: {
|
|
107
|
+
index: 3,
|
|
108
|
+
isWritable: false as boolean,
|
|
109
|
+
value: input.systemProgram ?? null,
|
|
110
|
+
},
|
|
111
|
+
} satisfies ResolvedAccountsWithIndices;
|
|
112
|
+
|
|
113
|
+
// Arguments.
|
|
114
|
+
const resolvedArgs: SetPeerConfigInstructionArgs = { ...input };
|
|
115
|
+
|
|
116
|
+
// Default values.
|
|
117
|
+
if (!resolvedAccounts.systemProgram.value) {
|
|
118
|
+
resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
|
|
119
|
+
'splSystem',
|
|
120
|
+
'11111111111111111111111111111111'
|
|
121
|
+
);
|
|
122
|
+
resolvedAccounts.systemProgram.isWritable = false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Accounts in order.
|
|
126
|
+
const orderedAccounts: ResolvedAccount[] = Object.values(
|
|
127
|
+
resolvedAccounts
|
|
128
|
+
).sort((a, b) => a.index - b.index);
|
|
129
|
+
|
|
130
|
+
// Keys and Signers.
|
|
131
|
+
const [keys, signers] = getAccountMetasAndSigners(
|
|
132
|
+
orderedAccounts,
|
|
133
|
+
'programId',
|
|
134
|
+
programId
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// Data.
|
|
138
|
+
const data = getSetPeerConfigInstructionDataSerializer().serialize(
|
|
139
|
+
resolvedArgs as SetPeerConfigInstructionDataArgs
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
// Bytes Created On Chain.
|
|
143
|
+
const bytesCreatedOnChain = 0;
|
|
144
|
+
|
|
145
|
+
return transactionBuilder([
|
|
146
|
+
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
|
|
147
|
+
]);
|
|
148
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
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
|
+
u64,
|
|
23
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
24
|
+
import {
|
|
25
|
+
ResolvedAccount,
|
|
26
|
+
ResolvedAccountsWithIndices,
|
|
27
|
+
getAccountMetasAndSigners,
|
|
28
|
+
} from '../shared';
|
|
29
|
+
|
|
30
|
+
// Accounts.
|
|
31
|
+
export type WithdrawFeeInstructionAccounts = {
|
|
32
|
+
admin: Signer;
|
|
33
|
+
oftStore: PublicKey | Pda;
|
|
34
|
+
tokenMint: PublicKey | Pda;
|
|
35
|
+
tokenEscrow: PublicKey | Pda;
|
|
36
|
+
tokenDest: PublicKey | Pda;
|
|
37
|
+
tokenProgram?: PublicKey | Pda;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Data.
|
|
41
|
+
export type WithdrawFeeInstructionData = {
|
|
42
|
+
discriminator: Uint8Array;
|
|
43
|
+
feeLd: bigint;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type WithdrawFeeInstructionDataArgs = { feeLd: number | bigint };
|
|
47
|
+
|
|
48
|
+
export function getWithdrawFeeInstructionDataSerializer(): Serializer<
|
|
49
|
+
WithdrawFeeInstructionDataArgs,
|
|
50
|
+
WithdrawFeeInstructionData
|
|
51
|
+
> {
|
|
52
|
+
return mapSerializer<
|
|
53
|
+
WithdrawFeeInstructionDataArgs,
|
|
54
|
+
any,
|
|
55
|
+
WithdrawFeeInstructionData
|
|
56
|
+
>(
|
|
57
|
+
struct<WithdrawFeeInstructionData>(
|
|
58
|
+
[
|
|
59
|
+
['discriminator', bytes({ size: 8 })],
|
|
60
|
+
['feeLd', u64()],
|
|
61
|
+
],
|
|
62
|
+
{ description: 'WithdrawFeeInstructionData' }
|
|
63
|
+
),
|
|
64
|
+
(value) => ({
|
|
65
|
+
...value,
|
|
66
|
+
discriminator: new Uint8Array([14, 122, 231, 218, 31, 238, 223, 150]),
|
|
67
|
+
})
|
|
68
|
+
) as Serializer<WithdrawFeeInstructionDataArgs, WithdrawFeeInstructionData>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Args.
|
|
72
|
+
export type WithdrawFeeInstructionArgs = WithdrawFeeInstructionDataArgs;
|
|
73
|
+
|
|
74
|
+
// Instruction.
|
|
75
|
+
export function withdrawFee(
|
|
76
|
+
context: Pick<Context, 'programs'>,
|
|
77
|
+
input: WithdrawFeeInstructionAccounts & WithdrawFeeInstructionArgs
|
|
78
|
+
): TransactionBuilder {
|
|
79
|
+
// Program ID.
|
|
80
|
+
const programId = context.programs.getPublicKey('oft', '');
|
|
81
|
+
|
|
82
|
+
// Accounts.
|
|
83
|
+
const resolvedAccounts = {
|
|
84
|
+
admin: {
|
|
85
|
+
index: 0,
|
|
86
|
+
isWritable: false as boolean,
|
|
87
|
+
value: input.admin ?? null,
|
|
88
|
+
},
|
|
89
|
+
oftStore: {
|
|
90
|
+
index: 1,
|
|
91
|
+
isWritable: false as boolean,
|
|
92
|
+
value: input.oftStore ?? null,
|
|
93
|
+
},
|
|
94
|
+
tokenMint: {
|
|
95
|
+
index: 2,
|
|
96
|
+
isWritable: false as boolean,
|
|
97
|
+
value: input.tokenMint ?? null,
|
|
98
|
+
},
|
|
99
|
+
tokenEscrow: {
|
|
100
|
+
index: 3,
|
|
101
|
+
isWritable: true as boolean,
|
|
102
|
+
value: input.tokenEscrow ?? null,
|
|
103
|
+
},
|
|
104
|
+
tokenDest: {
|
|
105
|
+
index: 4,
|
|
106
|
+
isWritable: true as boolean,
|
|
107
|
+
value: input.tokenDest ?? null,
|
|
108
|
+
},
|
|
109
|
+
tokenProgram: {
|
|
110
|
+
index: 5,
|
|
111
|
+
isWritable: false as boolean,
|
|
112
|
+
value: input.tokenProgram ?? null,
|
|
113
|
+
},
|
|
114
|
+
} satisfies ResolvedAccountsWithIndices;
|
|
115
|
+
|
|
116
|
+
// Arguments.
|
|
117
|
+
const resolvedArgs: WithdrawFeeInstructionArgs = { ...input };
|
|
118
|
+
|
|
119
|
+
// Default values.
|
|
120
|
+
if (!resolvedAccounts.tokenProgram.value) {
|
|
121
|
+
resolvedAccounts.tokenProgram.value = context.programs.getPublicKey(
|
|
122
|
+
'splToken',
|
|
123
|
+
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
|
124
|
+
);
|
|
125
|
+
resolvedAccounts.tokenProgram.isWritable = false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Accounts in order.
|
|
129
|
+
const orderedAccounts: ResolvedAccount[] = Object.values(
|
|
130
|
+
resolvedAccounts
|
|
131
|
+
).sort((a, b) => a.index - b.index);
|
|
132
|
+
|
|
133
|
+
// Keys and Signers.
|
|
134
|
+
const [keys, signers] = getAccountMetasAndSigners(
|
|
135
|
+
orderedAccounts,
|
|
136
|
+
'programId',
|
|
137
|
+
programId
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
// Data.
|
|
141
|
+
const data = getWithdrawFeeInstructionDataSerializer().serialize(
|
|
142
|
+
resolvedArgs as WithdrawFeeInstructionDataArgs
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
// Bytes Created On Chain.
|
|
146
|
+
const bytesCreatedOnChain = 0;
|
|
147
|
+
|
|
148
|
+
return transactionBuilder([
|
|
149
|
+
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
ClusterFilter,
|
|
11
|
+
Context,
|
|
12
|
+
Program,
|
|
13
|
+
PublicKey,
|
|
14
|
+
} from '@metaplex-foundation/umi';
|
|
15
|
+
import { getOftErrorFromCode, getOftErrorFromName } from '../errors';
|
|
16
|
+
|
|
17
|
+
export const OFT_PROGRAM_ID = '' as PublicKey<''>;
|
|
18
|
+
|
|
19
|
+
export function createOftProgram(): Program {
|
|
20
|
+
return {
|
|
21
|
+
name: 'oft',
|
|
22
|
+
publicKey: OFT_PROGRAM_ID,
|
|
23
|
+
getErrorFromCode(code: number, cause?: Error) {
|
|
24
|
+
return getOftErrorFromCode(code, this, cause);
|
|
25
|
+
},
|
|
26
|
+
getErrorFromName(name: string, cause?: Error) {
|
|
27
|
+
return getOftErrorFromName(name, this, cause);
|
|
28
|
+
},
|
|
29
|
+
isOnCluster() {
|
|
30
|
+
return true;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function getOftProgram<T extends Program = Program>(
|
|
36
|
+
context: Pick<Context, 'programs'>,
|
|
37
|
+
clusterFilter?: ClusterFilter
|
|
38
|
+
): T {
|
|
39
|
+
return context.programs.get<T>('oft', clusterFilter);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getOftProgramId(
|
|
43
|
+
context: Pick<Context, 'programs'>,
|
|
44
|
+
clusterFilter?: ClusterFilter
|
|
45
|
+
): PublicKey {
|
|
46
|
+
return context.programs.getPublicKey('oft', OFT_PROGRAM_ID, clusterFilter);
|
|
47
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
AccountMeta,
|
|
11
|
+
isSigner,
|
|
12
|
+
Pda,
|
|
13
|
+
publicKey,
|
|
14
|
+
PublicKey,
|
|
15
|
+
Signer,
|
|
16
|
+
isPda,
|
|
17
|
+
} from '@metaplex-foundation/umi';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Transforms the given object such that the given keys are optional.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export type PickPartial<T, K extends keyof T> = Omit<T, K> &
|
|
24
|
+
Partial<Pick<T, K>>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Asserts that the given value is not null or undefined.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export function expectSome<T>(value: T | null | undefined): T {
|
|
31
|
+
if (value == null) {
|
|
32
|
+
throw new Error('Expected a value but received null or undefined.');
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Asserts that the given value is a PublicKey.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export function expectPublicKey(
|
|
42
|
+
value: PublicKey | Pda | Signer | null | undefined
|
|
43
|
+
): PublicKey {
|
|
44
|
+
if (!value) {
|
|
45
|
+
throw new Error('Expected a PublicKey.');
|
|
46
|
+
}
|
|
47
|
+
return publicKey(value, false);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Asserts that the given value is a PDA.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export function expectPda(
|
|
55
|
+
value: PublicKey | Pda | Signer | null | undefined
|
|
56
|
+
): Pda {
|
|
57
|
+
if (!value || !Array.isArray(value) || !isPda(value)) {
|
|
58
|
+
throw new Error('Expected a PDA.');
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Defines an instruction account to resolve.
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
export type ResolvedAccount<T = PublicKey | Pda | Signer | null> = {
|
|
68
|
+
isWritable: boolean;
|
|
69
|
+
value: T;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Defines a set of instruction account to resolve.
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
export type ResolvedAccounts = Record<string, ResolvedAccount>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Defines a set of instruction account to resolve with their indices.
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
export type ResolvedAccountsWithIndices = Record<
|
|
83
|
+
string,
|
|
84
|
+
ResolvedAccount & { index: number }
|
|
85
|
+
>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get account metas and signers from resolved accounts.
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
export function getAccountMetasAndSigners(
|
|
92
|
+
accounts: ResolvedAccount[],
|
|
93
|
+
optionalAccountStrategy: 'omitted' | 'programId',
|
|
94
|
+
programId: PublicKey
|
|
95
|
+
): [AccountMeta[], Signer[]] {
|
|
96
|
+
const keys: AccountMeta[] = [];
|
|
97
|
+
const signers: Signer[] = [];
|
|
98
|
+
|
|
99
|
+
accounts.forEach((account) => {
|
|
100
|
+
if (!account.value) {
|
|
101
|
+
if (optionalAccountStrategy === 'omitted') return;
|
|
102
|
+
keys.push({ pubkey: programId, isSigner: false, isWritable: false });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (isSigner(account.value)) {
|
|
107
|
+
signers.push(account.value);
|
|
108
|
+
}
|
|
109
|
+
keys.push({
|
|
110
|
+
pubkey: publicKey(account.value, false),
|
|
111
|
+
isSigner: isSigner(account.value),
|
|
112
|
+
isWritable: account.isWritable,
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return [keys, signers];
|
|
117
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
Serializer,
|
|
11
|
+
bytes,
|
|
12
|
+
struct,
|
|
13
|
+
u32,
|
|
14
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
15
|
+
|
|
16
|
+
export type EnforcedOptions = { send: Uint8Array; sendAndCall: Uint8Array };
|
|
17
|
+
|
|
18
|
+
export type EnforcedOptionsArgs = EnforcedOptions;
|
|
19
|
+
|
|
20
|
+
export function getEnforcedOptionsSerializer(): Serializer<
|
|
21
|
+
EnforcedOptionsArgs,
|
|
22
|
+
EnforcedOptions
|
|
23
|
+
> {
|
|
24
|
+
return struct<EnforcedOptions>(
|
|
25
|
+
[
|
|
26
|
+
['send', bytes({ size: u32() })],
|
|
27
|
+
['sendAndCall', bytes({ size: u32() })],
|
|
28
|
+
],
|
|
29
|
+
{ description: 'EnforcedOptions' }
|
|
30
|
+
) as Serializer<EnforcedOptionsArgs, EnforcedOptions>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { PublicKey } from '@metaplex-foundation/umi';
|
|
10
|
+
import {
|
|
11
|
+
Serializer,
|
|
12
|
+
bool,
|
|
13
|
+
publicKey as publicKeySerializer,
|
|
14
|
+
struct,
|
|
15
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
16
|
+
|
|
17
|
+
/** same to anchor_lang::prelude::AccountMeta */
|
|
18
|
+
export type LzAccount = {
|
|
19
|
+
pubkey: PublicKey;
|
|
20
|
+
isSigner: boolean;
|
|
21
|
+
isWritable: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type LzAccountArgs = LzAccount;
|
|
25
|
+
|
|
26
|
+
export function getLzAccountSerializer(): Serializer<LzAccountArgs, LzAccount> {
|
|
27
|
+
return struct<LzAccount>(
|
|
28
|
+
[
|
|
29
|
+
['pubkey', publicKeySerializer()],
|
|
30
|
+
['isSigner', bool()],
|
|
31
|
+
['isWritable', bool()],
|
|
32
|
+
],
|
|
33
|
+
{ description: 'LzAccount' }
|
|
34
|
+
) as Serializer<LzAccountArgs, LzAccount>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
Serializer,
|
|
11
|
+
bytes,
|
|
12
|
+
struct,
|
|
13
|
+
u32,
|
|
14
|
+
u64,
|
|
15
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
16
|
+
|
|
17
|
+
export type LzReceiveParams = {
|
|
18
|
+
srcEid: number;
|
|
19
|
+
sender: Uint8Array;
|
|
20
|
+
nonce: bigint;
|
|
21
|
+
guid: Uint8Array;
|
|
22
|
+
message: Uint8Array;
|
|
23
|
+
extraData: Uint8Array;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type LzReceiveParamsArgs = {
|
|
27
|
+
srcEid: number;
|
|
28
|
+
sender: Uint8Array;
|
|
29
|
+
nonce: number | bigint;
|
|
30
|
+
guid: Uint8Array;
|
|
31
|
+
message: Uint8Array;
|
|
32
|
+
extraData: Uint8Array;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function getLzReceiveParamsSerializer(): Serializer<
|
|
36
|
+
LzReceiveParamsArgs,
|
|
37
|
+
LzReceiveParams
|
|
38
|
+
> {
|
|
39
|
+
return struct<LzReceiveParams>(
|
|
40
|
+
[
|
|
41
|
+
['srcEid', u32()],
|
|
42
|
+
['sender', bytes({ size: 32 })],
|
|
43
|
+
['nonce', u64()],
|
|
44
|
+
['guid', bytes({ size: 32 })],
|
|
45
|
+
['message', bytes({ size: u32() })],
|
|
46
|
+
['extraData', bytes({ size: u32() })],
|
|
47
|
+
],
|
|
48
|
+
{ description: 'LzReceiveParams' }
|
|
49
|
+
) as Serializer<LzReceiveParamsArgs, LzReceiveParams>;
|
|
50
|
+
}
|