@layerzerolabs/oft-v2-solana-sdk 3.0.47 → 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 +10 -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/deployments/solana-sandbox-local/TokenFourOFTAdapter.json +0 -15
- /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,198 @@
|
|
|
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
|
+
Account,
|
|
11
|
+
Context,
|
|
12
|
+
Option,
|
|
13
|
+
OptionOrNullable,
|
|
14
|
+
Pda,
|
|
15
|
+
PublicKey,
|
|
16
|
+
RpcAccount,
|
|
17
|
+
RpcGetAccountOptions,
|
|
18
|
+
RpcGetAccountsOptions,
|
|
19
|
+
assertAccountExists,
|
|
20
|
+
deserializeAccount,
|
|
21
|
+
gpaBuilder,
|
|
22
|
+
publicKey as toPublicKey,
|
|
23
|
+
} from '@metaplex-foundation/umi';
|
|
24
|
+
import {
|
|
25
|
+
Serializer,
|
|
26
|
+
bool,
|
|
27
|
+
bytes,
|
|
28
|
+
mapSerializer,
|
|
29
|
+
option,
|
|
30
|
+
publicKey as publicKeySerializer,
|
|
31
|
+
struct,
|
|
32
|
+
u16,
|
|
33
|
+
u64,
|
|
34
|
+
u8,
|
|
35
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
36
|
+
import { OFTType, OFTTypeArgs, getOFTTypeSerializer } from '../types';
|
|
37
|
+
|
|
38
|
+
export type OFTStore = Account<OFTStoreAccountData>;
|
|
39
|
+
|
|
40
|
+
export type OFTStoreAccountData = {
|
|
41
|
+
discriminator: Uint8Array;
|
|
42
|
+
oftType: OFTType;
|
|
43
|
+
ld2sdRate: bigint;
|
|
44
|
+
tokenMint: PublicKey;
|
|
45
|
+
tokenEscrow: PublicKey;
|
|
46
|
+
endpointProgram: PublicKey;
|
|
47
|
+
bump: number;
|
|
48
|
+
tvlLd: bigint;
|
|
49
|
+
admin: PublicKey;
|
|
50
|
+
defaultFeeBps: number;
|
|
51
|
+
paused: boolean;
|
|
52
|
+
pauser: Option<PublicKey>;
|
|
53
|
+
unpauser: Option<PublicKey>;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type OFTStoreAccountDataArgs = {
|
|
57
|
+
oftType: OFTTypeArgs;
|
|
58
|
+
ld2sdRate: number | bigint;
|
|
59
|
+
tokenMint: PublicKey;
|
|
60
|
+
tokenEscrow: PublicKey;
|
|
61
|
+
endpointProgram: PublicKey;
|
|
62
|
+
bump: number;
|
|
63
|
+
tvlLd: number | bigint;
|
|
64
|
+
admin: PublicKey;
|
|
65
|
+
defaultFeeBps: number;
|
|
66
|
+
paused: boolean;
|
|
67
|
+
pauser: OptionOrNullable<PublicKey>;
|
|
68
|
+
unpauser: OptionOrNullable<PublicKey>;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export function getOFTStoreAccountDataSerializer(): Serializer<
|
|
72
|
+
OFTStoreAccountDataArgs,
|
|
73
|
+
OFTStoreAccountData
|
|
74
|
+
> {
|
|
75
|
+
return mapSerializer<OFTStoreAccountDataArgs, any, OFTStoreAccountData>(
|
|
76
|
+
struct<OFTStoreAccountData>(
|
|
77
|
+
[
|
|
78
|
+
['discriminator', bytes({ size: 8 })],
|
|
79
|
+
['oftType', getOFTTypeSerializer()],
|
|
80
|
+
['ld2sdRate', u64()],
|
|
81
|
+
['tokenMint', publicKeySerializer()],
|
|
82
|
+
['tokenEscrow', publicKeySerializer()],
|
|
83
|
+
['endpointProgram', publicKeySerializer()],
|
|
84
|
+
['bump', u8()],
|
|
85
|
+
['tvlLd', u64()],
|
|
86
|
+
['admin', publicKeySerializer()],
|
|
87
|
+
['defaultFeeBps', u16()],
|
|
88
|
+
['paused', bool()],
|
|
89
|
+
['pauser', option(publicKeySerializer())],
|
|
90
|
+
['unpauser', option(publicKeySerializer())],
|
|
91
|
+
],
|
|
92
|
+
{ description: 'OFTStoreAccountData' }
|
|
93
|
+
),
|
|
94
|
+
(value) => ({
|
|
95
|
+
...value,
|
|
96
|
+
discriminator: new Uint8Array([195, 215, 104, 134, 185, 195, 240, 114]),
|
|
97
|
+
})
|
|
98
|
+
) as Serializer<OFTStoreAccountDataArgs, OFTStoreAccountData>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function deserializeOFTStore(rawAccount: RpcAccount): OFTStore {
|
|
102
|
+
return deserializeAccount(rawAccount, getOFTStoreAccountDataSerializer());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function fetchOFTStore(
|
|
106
|
+
context: Pick<Context, 'rpc'>,
|
|
107
|
+
publicKey: PublicKey | Pda,
|
|
108
|
+
options?: RpcGetAccountOptions
|
|
109
|
+
): Promise<OFTStore> {
|
|
110
|
+
const maybeAccount = await context.rpc.getAccount(
|
|
111
|
+
toPublicKey(publicKey, false),
|
|
112
|
+
options
|
|
113
|
+
);
|
|
114
|
+
assertAccountExists(maybeAccount, 'OFTStore');
|
|
115
|
+
return deserializeOFTStore(maybeAccount);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export async function safeFetchOFTStore(
|
|
119
|
+
context: Pick<Context, 'rpc'>,
|
|
120
|
+
publicKey: PublicKey | Pda,
|
|
121
|
+
options?: RpcGetAccountOptions
|
|
122
|
+
): Promise<OFTStore | null> {
|
|
123
|
+
const maybeAccount = await context.rpc.getAccount(
|
|
124
|
+
toPublicKey(publicKey, false),
|
|
125
|
+
options
|
|
126
|
+
);
|
|
127
|
+
return maybeAccount.exists ? deserializeOFTStore(maybeAccount) : null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export async function fetchAllOFTStore(
|
|
131
|
+
context: Pick<Context, 'rpc'>,
|
|
132
|
+
publicKeys: Array<PublicKey | Pda>,
|
|
133
|
+
options?: RpcGetAccountsOptions
|
|
134
|
+
): Promise<OFTStore[]> {
|
|
135
|
+
const maybeAccounts = await context.rpc.getAccounts(
|
|
136
|
+
publicKeys.map((key) => toPublicKey(key, false)),
|
|
137
|
+
options
|
|
138
|
+
);
|
|
139
|
+
return maybeAccounts.map((maybeAccount) => {
|
|
140
|
+
assertAccountExists(maybeAccount, 'OFTStore');
|
|
141
|
+
return deserializeOFTStore(maybeAccount);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export async function safeFetchAllOFTStore(
|
|
146
|
+
context: Pick<Context, 'rpc'>,
|
|
147
|
+
publicKeys: Array<PublicKey | Pda>,
|
|
148
|
+
options?: RpcGetAccountsOptions
|
|
149
|
+
): Promise<OFTStore[]> {
|
|
150
|
+
const maybeAccounts = await context.rpc.getAccounts(
|
|
151
|
+
publicKeys.map((key) => toPublicKey(key, false)),
|
|
152
|
+
options
|
|
153
|
+
);
|
|
154
|
+
return maybeAccounts
|
|
155
|
+
.filter((maybeAccount) => maybeAccount.exists)
|
|
156
|
+
.map((maybeAccount) => deserializeOFTStore(maybeAccount as RpcAccount));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function getOFTStoreGpaBuilder(
|
|
160
|
+
context: Pick<Context, 'rpc' | 'programs'>
|
|
161
|
+
) {
|
|
162
|
+
const programId = context.programs.getPublicKey('oft', '');
|
|
163
|
+
return gpaBuilder(context, programId)
|
|
164
|
+
.registerFields<{
|
|
165
|
+
discriminator: Uint8Array;
|
|
166
|
+
oftType: OFTTypeArgs;
|
|
167
|
+
ld2sdRate: number | bigint;
|
|
168
|
+
tokenMint: PublicKey;
|
|
169
|
+
tokenEscrow: PublicKey;
|
|
170
|
+
endpointProgram: PublicKey;
|
|
171
|
+
bump: number;
|
|
172
|
+
tvlLd: number | bigint;
|
|
173
|
+
admin: PublicKey;
|
|
174
|
+
defaultFeeBps: number;
|
|
175
|
+
paused: boolean;
|
|
176
|
+
pauser: OptionOrNullable<PublicKey>;
|
|
177
|
+
unpauser: OptionOrNullable<PublicKey>;
|
|
178
|
+
}>({
|
|
179
|
+
discriminator: [0, bytes({ size: 8 })],
|
|
180
|
+
oftType: [8, getOFTTypeSerializer()],
|
|
181
|
+
ld2sdRate: [9, u64()],
|
|
182
|
+
tokenMint: [17, publicKeySerializer()],
|
|
183
|
+
tokenEscrow: [49, publicKeySerializer()],
|
|
184
|
+
endpointProgram: [81, publicKeySerializer()],
|
|
185
|
+
bump: [113, u8()],
|
|
186
|
+
tvlLd: [114, u64()],
|
|
187
|
+
admin: [122, publicKeySerializer()],
|
|
188
|
+
defaultFeeBps: [154, u16()],
|
|
189
|
+
paused: [156, bool()],
|
|
190
|
+
pauser: [157, option(publicKeySerializer())],
|
|
191
|
+
unpauser: [null, option(publicKeySerializer())],
|
|
192
|
+
})
|
|
193
|
+
.deserializeUsing<OFTStore>((account) => deserializeOFTStore(account))
|
|
194
|
+
.whereField(
|
|
195
|
+
'discriminator',
|
|
196
|
+
new Uint8Array([195, 215, 104, 134, 185, 195, 240, 114])
|
|
197
|
+
);
|
|
198
|
+
}
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
RpcGetAccountOptions,
|
|
18
18
|
RpcGetAccountsOptions,
|
|
19
19
|
assertAccountExists,
|
|
20
|
-
defaultPublicKey,
|
|
21
20
|
deserializeAccount,
|
|
22
21
|
gpaBuilder,
|
|
23
22
|
publicKey as toPublicKey,
|
|
@@ -146,7 +145,7 @@ export async function safeFetchAllPeerConfig(
|
|
|
146
145
|
export function getPeerConfigGpaBuilder(
|
|
147
146
|
context: Pick<Context, 'rpc' | 'programs'>
|
|
148
147
|
) {
|
|
149
|
-
const programId = context.programs.getPublicKey('oft',
|
|
148
|
+
const programId = context.programs.getPublicKey('oft', '');
|
|
150
149
|
return gpaBuilder(context, programId)
|
|
151
150
|
.registerFields<{
|
|
152
151
|
discriminator: Uint8Array;
|
|
@@ -0,0 +1,159 @@
|
|
|
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 { Program, ProgramError } from '@metaplex-foundation/umi';
|
|
10
|
+
|
|
11
|
+
type ProgramErrorConstructor = new (
|
|
12
|
+
program: Program,
|
|
13
|
+
cause?: Error
|
|
14
|
+
) => ProgramError;
|
|
15
|
+
const codeToErrorMap: Map<number, ProgramErrorConstructor> = new Map();
|
|
16
|
+
const nameToErrorMap: Map<string, ProgramErrorConstructor> = new Map();
|
|
17
|
+
|
|
18
|
+
/** Unauthorized */
|
|
19
|
+
export class UnauthorizedError extends ProgramError {
|
|
20
|
+
override readonly name: string = 'Unauthorized';
|
|
21
|
+
|
|
22
|
+
readonly code: number = 0x1770; // 6000
|
|
23
|
+
|
|
24
|
+
constructor(program: Program, cause?: Error) {
|
|
25
|
+
super('', program, cause);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
codeToErrorMap.set(0x1770, UnauthorizedError);
|
|
29
|
+
nameToErrorMap.set('Unauthorized', UnauthorizedError);
|
|
30
|
+
|
|
31
|
+
/** InvalidSender */
|
|
32
|
+
export class InvalidSenderError extends ProgramError {
|
|
33
|
+
override readonly name: string = 'InvalidSender';
|
|
34
|
+
|
|
35
|
+
readonly code: number = 0x1771; // 6001
|
|
36
|
+
|
|
37
|
+
constructor(program: Program, cause?: Error) {
|
|
38
|
+
super('', program, cause);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
codeToErrorMap.set(0x1771, InvalidSenderError);
|
|
42
|
+
nameToErrorMap.set('InvalidSender', InvalidSenderError);
|
|
43
|
+
|
|
44
|
+
/** InvalidDecimals */
|
|
45
|
+
export class InvalidDecimalsError extends ProgramError {
|
|
46
|
+
override readonly name: string = 'InvalidDecimals';
|
|
47
|
+
|
|
48
|
+
readonly code: number = 0x1772; // 6002
|
|
49
|
+
|
|
50
|
+
constructor(program: Program, cause?: Error) {
|
|
51
|
+
super('', program, cause);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
codeToErrorMap.set(0x1772, InvalidDecimalsError);
|
|
55
|
+
nameToErrorMap.set('InvalidDecimals', InvalidDecimalsError);
|
|
56
|
+
|
|
57
|
+
/** SlippageExceeded */
|
|
58
|
+
export class SlippageExceededError extends ProgramError {
|
|
59
|
+
override readonly name: string = 'SlippageExceeded';
|
|
60
|
+
|
|
61
|
+
readonly code: number = 0x1773; // 6003
|
|
62
|
+
|
|
63
|
+
constructor(program: Program, cause?: Error) {
|
|
64
|
+
super('', program, cause);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
codeToErrorMap.set(0x1773, SlippageExceededError);
|
|
68
|
+
nameToErrorMap.set('SlippageExceeded', SlippageExceededError);
|
|
69
|
+
|
|
70
|
+
/** InvalidTokenDest */
|
|
71
|
+
export class InvalidTokenDestError extends ProgramError {
|
|
72
|
+
override readonly name: string = 'InvalidTokenDest';
|
|
73
|
+
|
|
74
|
+
readonly code: number = 0x1774; // 6004
|
|
75
|
+
|
|
76
|
+
constructor(program: Program, cause?: Error) {
|
|
77
|
+
super('', program, cause);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
codeToErrorMap.set(0x1774, InvalidTokenDestError);
|
|
81
|
+
nameToErrorMap.set('InvalidTokenDest', InvalidTokenDestError);
|
|
82
|
+
|
|
83
|
+
/** RateLimitExceeded */
|
|
84
|
+
export class RateLimitExceededError extends ProgramError {
|
|
85
|
+
override readonly name: string = 'RateLimitExceeded';
|
|
86
|
+
|
|
87
|
+
readonly code: number = 0x1775; // 6005
|
|
88
|
+
|
|
89
|
+
constructor(program: Program, cause?: Error) {
|
|
90
|
+
super('', program, cause);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
codeToErrorMap.set(0x1775, RateLimitExceededError);
|
|
94
|
+
nameToErrorMap.set('RateLimitExceeded', RateLimitExceededError);
|
|
95
|
+
|
|
96
|
+
/** InvalidFee */
|
|
97
|
+
export class InvalidFeeError extends ProgramError {
|
|
98
|
+
override readonly name: string = 'InvalidFee';
|
|
99
|
+
|
|
100
|
+
readonly code: number = 0x1776; // 6006
|
|
101
|
+
|
|
102
|
+
constructor(program: Program, cause?: Error) {
|
|
103
|
+
super('', program, cause);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
codeToErrorMap.set(0x1776, InvalidFeeError);
|
|
107
|
+
nameToErrorMap.set('InvalidFee', InvalidFeeError);
|
|
108
|
+
|
|
109
|
+
/** InvalidMintAuthority */
|
|
110
|
+
export class InvalidMintAuthorityError extends ProgramError {
|
|
111
|
+
override readonly name: string = 'InvalidMintAuthority';
|
|
112
|
+
|
|
113
|
+
readonly code: number = 0x1777; // 6007
|
|
114
|
+
|
|
115
|
+
constructor(program: Program, cause?: Error) {
|
|
116
|
+
super('', program, cause);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
codeToErrorMap.set(0x1777, InvalidMintAuthorityError);
|
|
120
|
+
nameToErrorMap.set('InvalidMintAuthority', InvalidMintAuthorityError);
|
|
121
|
+
|
|
122
|
+
/** Paused */
|
|
123
|
+
export class PausedError extends ProgramError {
|
|
124
|
+
override readonly name: string = 'Paused';
|
|
125
|
+
|
|
126
|
+
readonly code: number = 0x1778; // 6008
|
|
127
|
+
|
|
128
|
+
constructor(program: Program, cause?: Error) {
|
|
129
|
+
super('', program, cause);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
codeToErrorMap.set(0x1778, PausedError);
|
|
133
|
+
nameToErrorMap.set('Paused', PausedError);
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Attempts to resolve a custom program error from the provided error code.
|
|
137
|
+
* @category Errors
|
|
138
|
+
*/
|
|
139
|
+
export function getOftErrorFromCode(
|
|
140
|
+
code: number,
|
|
141
|
+
program: Program,
|
|
142
|
+
cause?: Error
|
|
143
|
+
): ProgramError | null {
|
|
144
|
+
const constructor = codeToErrorMap.get(code);
|
|
145
|
+
return constructor ? new constructor(program, cause) : null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Attempts to resolve a custom program error from the provided error name, i.e. 'Unauthorized'.
|
|
150
|
+
* @category Errors
|
|
151
|
+
*/
|
|
152
|
+
export function getOftErrorFromName(
|
|
153
|
+
name: string,
|
|
154
|
+
program: Program,
|
|
155
|
+
cause?: Error
|
|
156
|
+
): ProgramError | null {
|
|
157
|
+
const constructor = nameToErrorMap.get(name);
|
|
158
|
+
return constructor ? new constructor(program, cause) : null;
|
|
159
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
export * from './accounts';
|
|
10
|
+
export * from './errors';
|
|
11
|
+
export * from './instructions';
|
|
12
|
+
export * from './programs';
|
|
13
|
+
export * from './shared';
|
|
14
|
+
export * from './types';
|
|
@@ -0,0 +1,179 @@
|
|
|
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
|
+
Option,
|
|
12
|
+
OptionOrNullable,
|
|
13
|
+
Pda,
|
|
14
|
+
PublicKey,
|
|
15
|
+
Signer,
|
|
16
|
+
TransactionBuilder,
|
|
17
|
+
transactionBuilder,
|
|
18
|
+
} from '@metaplex-foundation/umi';
|
|
19
|
+
import {
|
|
20
|
+
Serializer,
|
|
21
|
+
bytes,
|
|
22
|
+
mapSerializer,
|
|
23
|
+
option,
|
|
24
|
+
publicKey as publicKeySerializer,
|
|
25
|
+
struct,
|
|
26
|
+
u8,
|
|
27
|
+
} from '@metaplex-foundation/umi/serializers';
|
|
28
|
+
import {
|
|
29
|
+
ResolvedAccount,
|
|
30
|
+
ResolvedAccountsWithIndices,
|
|
31
|
+
getAccountMetasAndSigners,
|
|
32
|
+
} from '../shared';
|
|
33
|
+
import { OFTType, OFTTypeArgs, getOFTTypeSerializer } from '../types';
|
|
34
|
+
|
|
35
|
+
// Accounts.
|
|
36
|
+
export type InitOftInstructionAccounts = {
|
|
37
|
+
payer?: Signer;
|
|
38
|
+
oftStore: PublicKey | Pda;
|
|
39
|
+
lzReceiveTypesAccounts: PublicKey | Pda;
|
|
40
|
+
tokenMint: PublicKey | Pda;
|
|
41
|
+
tokenEscrow: Signer;
|
|
42
|
+
tokenProgram?: PublicKey | Pda;
|
|
43
|
+
systemProgram?: PublicKey | Pda;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Data.
|
|
47
|
+
export type InitOftInstructionData = {
|
|
48
|
+
discriminator: Uint8Array;
|
|
49
|
+
oftType: OFTType;
|
|
50
|
+
admin: PublicKey;
|
|
51
|
+
sharedDecimals: number;
|
|
52
|
+
endpointProgram: Option<PublicKey>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type InitOftInstructionDataArgs = {
|
|
56
|
+
oftType: OFTTypeArgs;
|
|
57
|
+
admin: PublicKey;
|
|
58
|
+
sharedDecimals: number;
|
|
59
|
+
endpointProgram: OptionOrNullable<PublicKey>;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export function getInitOftInstructionDataSerializer(): Serializer<
|
|
63
|
+
InitOftInstructionDataArgs,
|
|
64
|
+
InitOftInstructionData
|
|
65
|
+
> {
|
|
66
|
+
return mapSerializer<InitOftInstructionDataArgs, any, InitOftInstructionData>(
|
|
67
|
+
struct<InitOftInstructionData>(
|
|
68
|
+
[
|
|
69
|
+
['discriminator', bytes({ size: 8 })],
|
|
70
|
+
['oftType', getOFTTypeSerializer()],
|
|
71
|
+
['admin', publicKeySerializer()],
|
|
72
|
+
['sharedDecimals', u8()],
|
|
73
|
+
['endpointProgram', option(publicKeySerializer())],
|
|
74
|
+
],
|
|
75
|
+
{ description: 'InitOftInstructionData' }
|
|
76
|
+
),
|
|
77
|
+
(value) => ({
|
|
78
|
+
...value,
|
|
79
|
+
discriminator: new Uint8Array([182, 169, 147, 16, 201, 45, 76, 23]),
|
|
80
|
+
})
|
|
81
|
+
) as Serializer<InitOftInstructionDataArgs, InitOftInstructionData>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Args.
|
|
85
|
+
export type InitOftInstructionArgs = InitOftInstructionDataArgs;
|
|
86
|
+
|
|
87
|
+
// Instruction.
|
|
88
|
+
export function initOft(
|
|
89
|
+
context: Pick<Context, 'payer' | 'programs'>,
|
|
90
|
+
input: InitOftInstructionAccounts & InitOftInstructionArgs
|
|
91
|
+
): TransactionBuilder {
|
|
92
|
+
// Program ID.
|
|
93
|
+
const programId = context.programs.getPublicKey('oft', '');
|
|
94
|
+
|
|
95
|
+
// Accounts.
|
|
96
|
+
const resolvedAccounts = {
|
|
97
|
+
payer: {
|
|
98
|
+
index: 0,
|
|
99
|
+
isWritable: true as boolean,
|
|
100
|
+
value: input.payer ?? null,
|
|
101
|
+
},
|
|
102
|
+
oftStore: {
|
|
103
|
+
index: 1,
|
|
104
|
+
isWritable: true as boolean,
|
|
105
|
+
value: input.oftStore ?? null,
|
|
106
|
+
},
|
|
107
|
+
lzReceiveTypesAccounts: {
|
|
108
|
+
index: 2,
|
|
109
|
+
isWritable: true as boolean,
|
|
110
|
+
value: input.lzReceiveTypesAccounts ?? null,
|
|
111
|
+
},
|
|
112
|
+
tokenMint: {
|
|
113
|
+
index: 3,
|
|
114
|
+
isWritable: false as boolean,
|
|
115
|
+
value: input.tokenMint ?? null,
|
|
116
|
+
},
|
|
117
|
+
tokenEscrow: {
|
|
118
|
+
index: 4,
|
|
119
|
+
isWritable: true as boolean,
|
|
120
|
+
value: input.tokenEscrow ?? null,
|
|
121
|
+
},
|
|
122
|
+
tokenProgram: {
|
|
123
|
+
index: 5,
|
|
124
|
+
isWritable: false as boolean,
|
|
125
|
+
value: input.tokenProgram ?? null,
|
|
126
|
+
},
|
|
127
|
+
systemProgram: {
|
|
128
|
+
index: 6,
|
|
129
|
+
isWritable: false as boolean,
|
|
130
|
+
value: input.systemProgram ?? null,
|
|
131
|
+
},
|
|
132
|
+
} satisfies ResolvedAccountsWithIndices;
|
|
133
|
+
|
|
134
|
+
// Arguments.
|
|
135
|
+
const resolvedArgs: InitOftInstructionArgs = { ...input };
|
|
136
|
+
|
|
137
|
+
// Default values.
|
|
138
|
+
if (!resolvedAccounts.payer.value) {
|
|
139
|
+
resolvedAccounts.payer.value = context.payer;
|
|
140
|
+
}
|
|
141
|
+
if (!resolvedAccounts.tokenProgram.value) {
|
|
142
|
+
resolvedAccounts.tokenProgram.value = context.programs.getPublicKey(
|
|
143
|
+
'splToken',
|
|
144
|
+
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
|
145
|
+
);
|
|
146
|
+
resolvedAccounts.tokenProgram.isWritable = false;
|
|
147
|
+
}
|
|
148
|
+
if (!resolvedAccounts.systemProgram.value) {
|
|
149
|
+
resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
|
|
150
|
+
'splSystem',
|
|
151
|
+
'11111111111111111111111111111111'
|
|
152
|
+
);
|
|
153
|
+
resolvedAccounts.systemProgram.isWritable = false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Accounts in order.
|
|
157
|
+
const orderedAccounts: ResolvedAccount[] = Object.values(
|
|
158
|
+
resolvedAccounts
|
|
159
|
+
).sort((a, b) => a.index - b.index);
|
|
160
|
+
|
|
161
|
+
// Keys and Signers.
|
|
162
|
+
const [keys, signers] = getAccountMetasAndSigners(
|
|
163
|
+
orderedAccounts,
|
|
164
|
+
'programId',
|
|
165
|
+
programId
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
// Data.
|
|
169
|
+
const data = getInitOftInstructionDataSerializer().serialize(
|
|
170
|
+
resolvedArgs as InitOftInstructionDataArgs
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
// Bytes Created On Chain.
|
|
174
|
+
const bytesCreatedOnChain = 0;
|
|
175
|
+
|
|
176
|
+
return transactionBuilder([
|
|
177
|
+
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
|
|
178
|
+
]);
|
|
179
|
+
}
|