@across-protocol/contracts 4.0.11 → 4.0.12
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/dist/scripts/svm/{enableRoute.js → createVault.js} +13 -35
- package/dist/scripts/svm/fakeFillWithRandomDistribution.js +9 -8
- package/dist/scripts/svm/nativeDeposit.js +138 -0
- package/dist/scripts/svm/queryEventsV2.js +3 -3
- package/dist/scripts/svm/{queryRoute.js → queryVault.js} +10 -25
- package/dist/scripts/svm/remoteHubPoolPauseDeposits.js +2 -2
- package/dist/scripts/svm/simpleDeposit.js +3 -12
- package/dist/scripts/svm/simpleFakeRelayerRepayment.js +2 -9
- package/dist/scripts/svm/simpleFill.js +3 -2
- package/dist/src/svm/assets/idl/svm_spoke.json +43 -369
- package/dist/src/svm/assets/svm_spoke.d.ts +40 -366
- package/dist/src/svm/clients/SvmSpoke/accounts/index.d.ts +0 -1
- package/dist/src/svm/clients/SvmSpoke/accounts/index.js +0 -1
- package/dist/src/svm/clients/SvmSpoke/errors/svmSpoke.d.ts +3 -1
- package/dist/src/svm/clients/SvmSpoke/errors/svmSpoke.js +4 -1
- package/dist/src/svm/clients/SvmSpoke/instructions/deposit.d.ts +21 -13
- package/dist/src/svm/clients/SvmSpoke/instructions/deposit.js +38 -6
- package/dist/src/svm/clients/SvmSpoke/instructions/depositNow.d.ts +21 -13
- package/dist/src/svm/clients/SvmSpoke/instructions/depositNow.js +38 -6
- package/dist/src/svm/clients/SvmSpoke/instructions/fillRelay.d.ts +20 -16
- package/dist/src/svm/clients/SvmSpoke/instructions/fillRelay.js +6 -1
- package/dist/src/svm/clients/SvmSpoke/instructions/index.d.ts +0 -1
- package/dist/src/svm/clients/SvmSpoke/instructions/index.js +0 -1
- package/dist/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.d.ts +21 -13
- package/dist/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.js +38 -6
- package/dist/src/svm/clients/SvmSpoke/programs/svmSpoke.d.ts +6 -10
- package/dist/src/svm/clients/SvmSpoke/programs/svmSpoke.js +5 -13
- package/dist/src/svm/clients/SvmSpoke/types/index.d.ts +0 -1
- package/dist/src/svm/clients/SvmSpoke/types/index.js +0 -1
- package/dist/src/svm/web3-v1/helpers.d.ts +114 -1
- package/dist/src/svm/web3-v1/helpers.js +179 -1
- package/dist/target/types/svm_spoke.d.ts +40 -366
- package/dist/test/svm/SvmSpoke.Deposit.js +143 -176
- package/dist/test/svm/SvmSpoke.Fill.AcrossPlus.js +20 -17
- package/dist/test/svm/SvmSpoke.Fill.js +52 -38
- package/dist/test/svm/SvmSpoke.HandleReceiveMessage.js +2 -114
- package/dist/test/svm/SvmSpoke.SlowFill.AcrossPlus.js +2 -2
- package/dist/test/svm/SvmSpoke.SlowFill.js +37 -34
- package/dist/test/svm/SvmSpoke.common.d.ts +2 -3
- package/dist/test/svm/SvmSpoke.common.js +3 -12
- package/package.json +1 -1
- package/dist/scripts/svm/remoteHubPoolSetDepositRoute.d.ts +0 -1
- package/dist/scripts/svm/remoteHubPoolSetDepositRoute.js +0 -252
- package/dist/src/svm/clients/SvmSpoke/accounts/route.d.ts +0 -27
- package/dist/src/svm/clients/SvmSpoke/accounts/route.js +0 -66
- package/dist/src/svm/clients/SvmSpoke/instructions/setEnableRoute.d.ts +0 -95
- package/dist/src/svm/clients/SvmSpoke/instructions/setEnableRoute.js +0 -213
- package/dist/src/svm/clients/SvmSpoke/types/enabledDepositRoute.d.ts +0 -21
- package/dist/src/svm/clients/SvmSpoke/types/enabledDepositRoute.js +0 -30
- package/dist/test/svm/SvmSpoke.Routes.js +0 -167
- /package/dist/scripts/svm/{enableRoute.d.ts → createVault.d.ts} +0 -0
- /package/dist/scripts/svm/{queryRoute.d.ts → nativeDeposit.d.ts} +0 -0
- /package/dist/{test/svm/SvmSpoke.Routes.d.ts → scripts/svm/queryVault.d.ts} +0 -0
|
@@ -9,14 +9,16 @@ import { type Address, type Codec, type Decoder, type Encoder, type IAccountMeta
|
|
|
9
9
|
import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs';
|
|
10
10
|
export declare const UNSAFE_DEPOSIT_DISCRIMINATOR: Uint8Array;
|
|
11
11
|
export declare function getUnsafeDepositDiscriminatorBytes(): ReadonlyUint8Array;
|
|
12
|
-
export type UnsafeDepositInstruction<TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, TAccountSigner extends string | IAccountMeta<string> = string, TAccountState extends string | IAccountMeta<string> = string,
|
|
12
|
+
export type UnsafeDepositInstruction<TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, TAccountSigner extends string | IAccountMeta<string> = string, TAccountState extends string | IAccountMeta<string> = string, TAccountDelegate extends string | IAccountMeta<string> = string, TAccountDepositorTokenAccount extends string | IAccountMeta<string> = string, TAccountVault extends string | IAccountMeta<string> = string, TAccountMint extends string | IAccountMeta<string> = string, TAccountTokenProgram extends string | IAccountMeta<string> = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', TAccountAssociatedTokenProgram extends string | IAccountMeta<string> = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', TAccountSystemProgram extends string | IAccountMeta<string> = '11111111111111111111111111111111', TAccountEventAuthority extends string | IAccountMeta<string> = string, TAccountProgram extends string | IAccountMeta<string> = string, TRemainingAccounts extends readonly IAccountMeta<string>[] = []> = IInstruction<TProgram> & IInstructionWithData<Uint8Array> & IInstructionWithAccounts<[
|
|
13
13
|
TAccountSigner extends string ? WritableSignerAccount<TAccountSigner> & IAccountSignerMeta<TAccountSigner> : TAccountSigner,
|
|
14
14
|
TAccountState extends string ? WritableAccount<TAccountState> : TAccountState,
|
|
15
|
-
|
|
15
|
+
TAccountDelegate extends string ? ReadonlyAccount<TAccountDelegate> : TAccountDelegate,
|
|
16
16
|
TAccountDepositorTokenAccount extends string ? WritableAccount<TAccountDepositorTokenAccount> : TAccountDepositorTokenAccount,
|
|
17
17
|
TAccountVault extends string ? WritableAccount<TAccountVault> : TAccountVault,
|
|
18
18
|
TAccountMint extends string ? ReadonlyAccount<TAccountMint> : TAccountMint,
|
|
19
19
|
TAccountTokenProgram extends string ? ReadonlyAccount<TAccountTokenProgram> : TAccountTokenProgram,
|
|
20
|
+
TAccountAssociatedTokenProgram extends string ? ReadonlyAccount<TAccountAssociatedTokenProgram> : TAccountAssociatedTokenProgram,
|
|
21
|
+
TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram,
|
|
20
22
|
TAccountEventAuthority extends string ? ReadonlyAccount<TAccountEventAuthority> : TAccountEventAuthority,
|
|
21
23
|
TAccountProgram extends string ? ReadonlyAccount<TAccountProgram> : TAccountProgram,
|
|
22
24
|
...TRemainingAccounts
|
|
@@ -55,14 +57,16 @@ export type UnsafeDepositInstructionDataArgs = {
|
|
|
55
57
|
export declare function getUnsafeDepositInstructionDataEncoder(): Encoder<UnsafeDepositInstructionDataArgs>;
|
|
56
58
|
export declare function getUnsafeDepositInstructionDataDecoder(): Decoder<UnsafeDepositInstructionData>;
|
|
57
59
|
export declare function getUnsafeDepositInstructionDataCodec(): Codec<UnsafeDepositInstructionDataArgs, UnsafeDepositInstructionData>;
|
|
58
|
-
export type UnsafeDepositAsyncInput<TAccountSigner extends string = string, TAccountState extends string = string,
|
|
60
|
+
export type UnsafeDepositAsyncInput<TAccountSigner extends string = string, TAccountState extends string = string, TAccountDelegate extends string = string, TAccountDepositorTokenAccount extends string = string, TAccountVault extends string = string, TAccountMint extends string = string, TAccountTokenProgram extends string = string, TAccountAssociatedTokenProgram extends string = string, TAccountSystemProgram extends string = string, TAccountEventAuthority extends string = string, TAccountProgram extends string = string> = {
|
|
59
61
|
signer: TransactionSigner<TAccountSigner>;
|
|
60
62
|
state: Address<TAccountState>;
|
|
61
|
-
|
|
63
|
+
delegate: Address<TAccountDelegate>;
|
|
62
64
|
depositorTokenAccount?: Address<TAccountDepositorTokenAccount>;
|
|
63
65
|
vault?: Address<TAccountVault>;
|
|
64
66
|
mint: Address<TAccountMint>;
|
|
65
67
|
tokenProgram?: Address<TAccountTokenProgram>;
|
|
68
|
+
associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
|
|
69
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
66
70
|
eventAuthority?: Address<TAccountEventAuthority>;
|
|
67
71
|
program: Address<TAccountProgram>;
|
|
68
72
|
depositor: UnsafeDepositInstructionDataArgs['depositor'];
|
|
@@ -79,17 +83,19 @@ export type UnsafeDepositAsyncInput<TAccountSigner extends string = string, TAcc
|
|
|
79
83
|
exclusivityParameter: UnsafeDepositInstructionDataArgs['exclusivityParameter'];
|
|
80
84
|
message: UnsafeDepositInstructionDataArgs['message'];
|
|
81
85
|
};
|
|
82
|
-
export declare function getUnsafeDepositInstructionAsync<TAccountSigner extends string, TAccountState extends string,
|
|
86
|
+
export declare function getUnsafeDepositInstructionAsync<TAccountSigner extends string, TAccountState extends string, TAccountDelegate extends string, TAccountDepositorTokenAccount extends string, TAccountVault extends string, TAccountMint extends string, TAccountTokenProgram extends string, TAccountAssociatedTokenProgram extends string, TAccountSystemProgram extends string, TAccountEventAuthority extends string, TAccountProgram extends string, TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS>(input: UnsafeDepositAsyncInput<TAccountSigner, TAccountState, TAccountDelegate, TAccountDepositorTokenAccount, TAccountVault, TAccountMint, TAccountTokenProgram, TAccountAssociatedTokenProgram, TAccountSystemProgram, TAccountEventAuthority, TAccountProgram>, config?: {
|
|
83
87
|
programAddress?: TProgramAddress;
|
|
84
|
-
}): Promise<UnsafeDepositInstruction<TProgramAddress, TAccountSigner, TAccountState,
|
|
85
|
-
export type UnsafeDepositInput<TAccountSigner extends string = string, TAccountState extends string = string,
|
|
88
|
+
}): Promise<UnsafeDepositInstruction<TProgramAddress, TAccountSigner, TAccountState, TAccountDelegate, TAccountDepositorTokenAccount, TAccountVault, TAccountMint, TAccountTokenProgram, TAccountAssociatedTokenProgram, TAccountSystemProgram, TAccountEventAuthority, TAccountProgram>>;
|
|
89
|
+
export type UnsafeDepositInput<TAccountSigner extends string = string, TAccountState extends string = string, TAccountDelegate extends string = string, TAccountDepositorTokenAccount extends string = string, TAccountVault extends string = string, TAccountMint extends string = string, TAccountTokenProgram extends string = string, TAccountAssociatedTokenProgram extends string = string, TAccountSystemProgram extends string = string, TAccountEventAuthority extends string = string, TAccountProgram extends string = string> = {
|
|
86
90
|
signer: TransactionSigner<TAccountSigner>;
|
|
87
91
|
state: Address<TAccountState>;
|
|
88
|
-
|
|
92
|
+
delegate: Address<TAccountDelegate>;
|
|
89
93
|
depositorTokenAccount: Address<TAccountDepositorTokenAccount>;
|
|
90
94
|
vault: Address<TAccountVault>;
|
|
91
95
|
mint: Address<TAccountMint>;
|
|
92
96
|
tokenProgram?: Address<TAccountTokenProgram>;
|
|
97
|
+
associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
|
|
98
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
93
99
|
eventAuthority: Address<TAccountEventAuthority>;
|
|
94
100
|
program: Address<TAccountProgram>;
|
|
95
101
|
depositor: UnsafeDepositInstructionDataArgs['depositor'];
|
|
@@ -106,21 +112,23 @@ export type UnsafeDepositInput<TAccountSigner extends string = string, TAccountS
|
|
|
106
112
|
exclusivityParameter: UnsafeDepositInstructionDataArgs['exclusivityParameter'];
|
|
107
113
|
message: UnsafeDepositInstructionDataArgs['message'];
|
|
108
114
|
};
|
|
109
|
-
export declare function getUnsafeDepositInstruction<TAccountSigner extends string, TAccountState extends string,
|
|
115
|
+
export declare function getUnsafeDepositInstruction<TAccountSigner extends string, TAccountState extends string, TAccountDelegate extends string, TAccountDepositorTokenAccount extends string, TAccountVault extends string, TAccountMint extends string, TAccountTokenProgram extends string, TAccountAssociatedTokenProgram extends string, TAccountSystemProgram extends string, TAccountEventAuthority extends string, TAccountProgram extends string, TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS>(input: UnsafeDepositInput<TAccountSigner, TAccountState, TAccountDelegate, TAccountDepositorTokenAccount, TAccountVault, TAccountMint, TAccountTokenProgram, TAccountAssociatedTokenProgram, TAccountSystemProgram, TAccountEventAuthority, TAccountProgram>, config?: {
|
|
110
116
|
programAddress?: TProgramAddress;
|
|
111
|
-
}): UnsafeDepositInstruction<TProgramAddress, TAccountSigner, TAccountState,
|
|
117
|
+
}): UnsafeDepositInstruction<TProgramAddress, TAccountSigner, TAccountState, TAccountDelegate, TAccountDepositorTokenAccount, TAccountVault, TAccountMint, TAccountTokenProgram, TAccountAssociatedTokenProgram, TAccountSystemProgram, TAccountEventAuthority, TAccountProgram>;
|
|
112
118
|
export type ParsedUnsafeDepositInstruction<TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[]> = {
|
|
113
119
|
programAddress: Address<TProgram>;
|
|
114
120
|
accounts: {
|
|
115
121
|
signer: TAccountMetas[0];
|
|
116
122
|
state: TAccountMetas[1];
|
|
117
|
-
|
|
123
|
+
delegate: TAccountMetas[2];
|
|
118
124
|
depositorTokenAccount: TAccountMetas[3];
|
|
119
125
|
vault: TAccountMetas[4];
|
|
120
126
|
mint: TAccountMetas[5];
|
|
121
127
|
tokenProgram: TAccountMetas[6];
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
associatedTokenProgram: TAccountMetas[7];
|
|
129
|
+
systemProgram: TAccountMetas[8];
|
|
130
|
+
eventAuthority: TAccountMetas[9];
|
|
131
|
+
program: TAccountMetas[10];
|
|
124
132
|
};
|
|
125
133
|
data: UnsafeDepositInstructionData;
|
|
126
134
|
};
|
|
@@ -70,7 +70,7 @@ async function getUnsafeDepositInstructionAsync(input, config) {
|
|
|
70
70
|
const originalAccounts = {
|
|
71
71
|
signer: { value: input.signer ?? null, isWritable: true },
|
|
72
72
|
state: { value: input.state ?? null, isWritable: true },
|
|
73
|
-
|
|
73
|
+
delegate: { value: input.delegate ?? null, isWritable: false },
|
|
74
74
|
depositorTokenAccount: {
|
|
75
75
|
value: input.depositorTokenAccount ?? null,
|
|
76
76
|
isWritable: true,
|
|
@@ -78,6 +78,11 @@ async function getUnsafeDepositInstructionAsync(input, config) {
|
|
|
78
78
|
vault: { value: input.vault ?? null, isWritable: true },
|
|
79
79
|
mint: { value: input.mint ?? null, isWritable: false },
|
|
80
80
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
81
|
+
associatedTokenProgram: {
|
|
82
|
+
value: input.associatedTokenProgram ?? null,
|
|
83
|
+
isWritable: false,
|
|
84
|
+
},
|
|
85
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
81
86
|
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
82
87
|
program: { value: input.program ?? null, isWritable: false },
|
|
83
88
|
};
|
|
@@ -109,6 +114,14 @@ async function getUnsafeDepositInstructionAsync(input, config) {
|
|
|
109
114
|
],
|
|
110
115
|
});
|
|
111
116
|
}
|
|
117
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
118
|
+
accounts.associatedTokenProgram.value =
|
|
119
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
120
|
+
}
|
|
121
|
+
if (!accounts.systemProgram.value) {
|
|
122
|
+
accounts.systemProgram.value =
|
|
123
|
+
'11111111111111111111111111111111';
|
|
124
|
+
}
|
|
112
125
|
if (!accounts.eventAuthority.value) {
|
|
113
126
|
accounts.eventAuthority.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
114
127
|
programAddress,
|
|
@@ -125,11 +138,13 @@ async function getUnsafeDepositInstructionAsync(input, config) {
|
|
|
125
138
|
accounts: [
|
|
126
139
|
getAccountMeta(accounts.signer),
|
|
127
140
|
getAccountMeta(accounts.state),
|
|
128
|
-
getAccountMeta(accounts.
|
|
141
|
+
getAccountMeta(accounts.delegate),
|
|
129
142
|
getAccountMeta(accounts.depositorTokenAccount),
|
|
130
143
|
getAccountMeta(accounts.vault),
|
|
131
144
|
getAccountMeta(accounts.mint),
|
|
132
145
|
getAccountMeta(accounts.tokenProgram),
|
|
146
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
147
|
+
getAccountMeta(accounts.systemProgram),
|
|
133
148
|
getAccountMeta(accounts.eventAuthority),
|
|
134
149
|
getAccountMeta(accounts.program),
|
|
135
150
|
],
|
|
@@ -145,7 +160,7 @@ function getUnsafeDepositInstruction(input, config) {
|
|
|
145
160
|
const originalAccounts = {
|
|
146
161
|
signer: { value: input.signer ?? null, isWritable: true },
|
|
147
162
|
state: { value: input.state ?? null, isWritable: true },
|
|
148
|
-
|
|
163
|
+
delegate: { value: input.delegate ?? null, isWritable: false },
|
|
149
164
|
depositorTokenAccount: {
|
|
150
165
|
value: input.depositorTokenAccount ?? null,
|
|
151
166
|
isWritable: true,
|
|
@@ -153,6 +168,11 @@ function getUnsafeDepositInstruction(input, config) {
|
|
|
153
168
|
vault: { value: input.vault ?? null, isWritable: true },
|
|
154
169
|
mint: { value: input.mint ?? null, isWritable: false },
|
|
155
170
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
171
|
+
associatedTokenProgram: {
|
|
172
|
+
value: input.associatedTokenProgram ?? null,
|
|
173
|
+
isWritable: false,
|
|
174
|
+
},
|
|
175
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
156
176
|
eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
|
|
157
177
|
program: { value: input.program ?? null, isWritable: false },
|
|
158
178
|
};
|
|
@@ -164,16 +184,26 @@ function getUnsafeDepositInstruction(input, config) {
|
|
|
164
184
|
accounts.tokenProgram.value =
|
|
165
185
|
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
166
186
|
}
|
|
187
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
188
|
+
accounts.associatedTokenProgram.value =
|
|
189
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
190
|
+
}
|
|
191
|
+
if (!accounts.systemProgram.value) {
|
|
192
|
+
accounts.systemProgram.value =
|
|
193
|
+
'11111111111111111111111111111111';
|
|
194
|
+
}
|
|
167
195
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
|
|
168
196
|
const instruction = {
|
|
169
197
|
accounts: [
|
|
170
198
|
getAccountMeta(accounts.signer),
|
|
171
199
|
getAccountMeta(accounts.state),
|
|
172
|
-
getAccountMeta(accounts.
|
|
200
|
+
getAccountMeta(accounts.delegate),
|
|
173
201
|
getAccountMeta(accounts.depositorTokenAccount),
|
|
174
202
|
getAccountMeta(accounts.vault),
|
|
175
203
|
getAccountMeta(accounts.mint),
|
|
176
204
|
getAccountMeta(accounts.tokenProgram),
|
|
205
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
206
|
+
getAccountMeta(accounts.systemProgram),
|
|
177
207
|
getAccountMeta(accounts.eventAuthority),
|
|
178
208
|
getAccountMeta(accounts.program),
|
|
179
209
|
],
|
|
@@ -183,7 +213,7 @@ function getUnsafeDepositInstruction(input, config) {
|
|
|
183
213
|
return instruction;
|
|
184
214
|
}
|
|
185
215
|
function parseUnsafeDepositInstruction(instruction) {
|
|
186
|
-
if (instruction.accounts.length <
|
|
216
|
+
if (instruction.accounts.length < 11) {
|
|
187
217
|
// TODO: Coded error.
|
|
188
218
|
throw new Error('Not enough accounts');
|
|
189
219
|
}
|
|
@@ -198,11 +228,13 @@ function parseUnsafeDepositInstruction(instruction) {
|
|
|
198
228
|
accounts: {
|
|
199
229
|
signer: getNextAccount(),
|
|
200
230
|
state: getNextAccount(),
|
|
201
|
-
|
|
231
|
+
delegate: getNextAccount(),
|
|
202
232
|
depositorTokenAccount: getNextAccount(),
|
|
203
233
|
vault: getNextAccount(),
|
|
204
234
|
mint: getNextAccount(),
|
|
205
235
|
tokenProgram: getNextAccount(),
|
|
236
|
+
associatedTokenProgram: getNextAccount(),
|
|
237
|
+
systemProgram: getNextAccount(),
|
|
206
238
|
eventAuthority: getNextAccount(),
|
|
207
239
|
program: getNextAccount(),
|
|
208
240
|
},
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @see https://github.com/codama-idl/codama
|
|
7
7
|
*/
|
|
8
8
|
import { type Address, type ReadonlyUint8Array } from '@solana/kit';
|
|
9
|
-
import { type ParsedBridgeTokensToHubPoolInstruction, type ParsedClaimRelayerRefundInstruction, type ParsedCloseClaimAccountInstruction, type ParsedCloseFillPdaInstruction, type ParsedCloseInstructionParamsInstruction, type ParsedCreateTokenAccountsInstruction, type ParsedDepositInstruction, type ParsedDepositNowInstruction, type ParsedEmergencyDeleteRootBundleInstruction, type ParsedExecuteRelayerRefundLeafDeferredInstruction, type ParsedExecuteRelayerRefundLeafInstruction, type ParsedExecuteSlowRelayLeafInstruction, type ParsedFillRelayInstruction, type ParsedGetUnsafeDepositIdInstruction, type ParsedHandleReceiveMessageInstruction, type ParsedInitializeClaimAccountInstruction, type ParsedInitializeInstruction, type ParsedInitializeInstructionParamsInstruction, type ParsedPauseDepositsInstruction, type ParsedPauseFillsInstruction, type ParsedRelayRootBundleInstruction, type ParsedRequestSlowFillInstruction, type ParsedSetCrossDomainAdminInstruction, type ParsedSetCurrentTimeInstruction, type
|
|
9
|
+
import { type ParsedBridgeTokensToHubPoolInstruction, type ParsedClaimRelayerRefundInstruction, type ParsedCloseClaimAccountInstruction, type ParsedCloseFillPdaInstruction, type ParsedCloseInstructionParamsInstruction, type ParsedCreateTokenAccountsInstruction, type ParsedDepositInstruction, type ParsedDepositNowInstruction, type ParsedEmergencyDeleteRootBundleInstruction, type ParsedExecuteRelayerRefundLeafDeferredInstruction, type ParsedExecuteRelayerRefundLeafInstruction, type ParsedExecuteSlowRelayLeafInstruction, type ParsedFillRelayInstruction, type ParsedGetUnsafeDepositIdInstruction, type ParsedHandleReceiveMessageInstruction, type ParsedInitializeClaimAccountInstruction, type ParsedInitializeInstruction, type ParsedInitializeInstructionParamsInstruction, type ParsedPauseDepositsInstruction, type ParsedPauseFillsInstruction, type ParsedRelayRootBundleInstruction, type ParsedRequestSlowFillInstruction, type ParsedSetCrossDomainAdminInstruction, type ParsedSetCurrentTimeInstruction, type ParsedTransferOwnershipInstruction, type ParsedUnsafeDepositInstruction, type ParsedWriteInstructionParamsFragmentInstruction } from '../instructions';
|
|
10
10
|
export declare const SVM_SPOKE_PROGRAM_ADDRESS: Address<"JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq">;
|
|
11
11
|
export declare enum SvmSpokeAccount {
|
|
12
12
|
ClaimAccount = 0,
|
|
@@ -16,9 +16,8 @@ export declare enum SvmSpokeAccount {
|
|
|
16
16
|
FillStatusAccount = 4,
|
|
17
17
|
RequestSlowFillParams = 5,
|
|
18
18
|
RootBundle = 6,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
TransferLiability = 9
|
|
19
|
+
State = 7,
|
|
20
|
+
TransferLiability = 8
|
|
22
21
|
}
|
|
23
22
|
export declare function identifySvmSpokeAccount(account: {
|
|
24
23
|
data: ReadonlyUint8Array;
|
|
@@ -48,10 +47,9 @@ export declare enum SvmSpokeInstruction {
|
|
|
48
47
|
RequestSlowFill = 21,
|
|
49
48
|
SetCrossDomainAdmin = 22,
|
|
50
49
|
SetCurrentTime = 23,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
WriteInstructionParamsFragment = 27
|
|
50
|
+
TransferOwnership = 24,
|
|
51
|
+
UnsafeDeposit = 25,
|
|
52
|
+
WriteInstructionParamsFragment = 26
|
|
55
53
|
}
|
|
56
54
|
export declare function identifySvmSpokeInstruction(instruction: {
|
|
57
55
|
data: ReadonlyUint8Array;
|
|
@@ -105,8 +103,6 @@ export type ParsedSvmSpokeInstruction<TProgram extends string = 'JAZWcGrpSWNPTBj
|
|
|
105
103
|
} & ParsedSetCrossDomainAdminInstruction<TProgram>) | ({
|
|
106
104
|
instructionType: SvmSpokeInstruction.SetCurrentTime;
|
|
107
105
|
} & ParsedSetCurrentTimeInstruction<TProgram>) | ({
|
|
108
|
-
instructionType: SvmSpokeInstruction.SetEnableRoute;
|
|
109
|
-
} & ParsedSetEnableRouteInstruction<TProgram>) | ({
|
|
110
106
|
instructionType: SvmSpokeInstruction.TransferOwnership;
|
|
111
107
|
} & ParsedTransferOwnershipInstruction<TProgram>) | ({
|
|
112
108
|
instructionType: SvmSpokeInstruction.UnsafeDeposit;
|
|
@@ -21,9 +21,8 @@ var SvmSpokeAccount;
|
|
|
21
21
|
SvmSpokeAccount[SvmSpokeAccount["FillStatusAccount"] = 4] = "FillStatusAccount";
|
|
22
22
|
SvmSpokeAccount[SvmSpokeAccount["RequestSlowFillParams"] = 5] = "RequestSlowFillParams";
|
|
23
23
|
SvmSpokeAccount[SvmSpokeAccount["RootBundle"] = 6] = "RootBundle";
|
|
24
|
-
SvmSpokeAccount[SvmSpokeAccount["
|
|
25
|
-
SvmSpokeAccount[SvmSpokeAccount["
|
|
26
|
-
SvmSpokeAccount[SvmSpokeAccount["TransferLiability"] = 9] = "TransferLiability";
|
|
24
|
+
SvmSpokeAccount[SvmSpokeAccount["State"] = 7] = "State";
|
|
25
|
+
SvmSpokeAccount[SvmSpokeAccount["TransferLiability"] = 8] = "TransferLiability";
|
|
27
26
|
})(SvmSpokeAccount || (exports.SvmSpokeAccount = SvmSpokeAccount = {}));
|
|
28
27
|
function identifySvmSpokeAccount(account) {
|
|
29
28
|
const data = 'data' in account ? account.data : account;
|
|
@@ -48,9 +47,6 @@ function identifySvmSpokeAccount(account) {
|
|
|
48
47
|
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([66, 221, 214, 231, 25, 222, 184, 219])), 0)) {
|
|
49
48
|
return SvmSpokeAccount.RootBundle;
|
|
50
49
|
}
|
|
51
|
-
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([80, 179, 58, 115, 52, 19, 146, 134])), 0)) {
|
|
52
|
-
return SvmSpokeAccount.Route;
|
|
53
|
-
}
|
|
54
50
|
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([216, 146, 107, 94, 104, 75, 182, 177])), 0)) {
|
|
55
51
|
return SvmSpokeAccount.State;
|
|
56
52
|
}
|
|
@@ -85,10 +81,9 @@ var SvmSpokeInstruction;
|
|
|
85
81
|
SvmSpokeInstruction[SvmSpokeInstruction["RequestSlowFill"] = 21] = "RequestSlowFill";
|
|
86
82
|
SvmSpokeInstruction[SvmSpokeInstruction["SetCrossDomainAdmin"] = 22] = "SetCrossDomainAdmin";
|
|
87
83
|
SvmSpokeInstruction[SvmSpokeInstruction["SetCurrentTime"] = 23] = "SetCurrentTime";
|
|
88
|
-
SvmSpokeInstruction[SvmSpokeInstruction["
|
|
89
|
-
SvmSpokeInstruction[SvmSpokeInstruction["
|
|
90
|
-
SvmSpokeInstruction[SvmSpokeInstruction["
|
|
91
|
-
SvmSpokeInstruction[SvmSpokeInstruction["WriteInstructionParamsFragment"] = 27] = "WriteInstructionParamsFragment";
|
|
84
|
+
SvmSpokeInstruction[SvmSpokeInstruction["TransferOwnership"] = 24] = "TransferOwnership";
|
|
85
|
+
SvmSpokeInstruction[SvmSpokeInstruction["UnsafeDeposit"] = 25] = "UnsafeDeposit";
|
|
86
|
+
SvmSpokeInstruction[SvmSpokeInstruction["WriteInstructionParamsFragment"] = 26] = "WriteInstructionParamsFragment";
|
|
92
87
|
})(SvmSpokeInstruction || (exports.SvmSpokeInstruction = SvmSpokeInstruction = {}));
|
|
93
88
|
function identifySvmSpokeInstruction(instruction) {
|
|
94
89
|
const data = 'data' in instruction ? instruction.data : instruction;
|
|
@@ -164,9 +159,6 @@ function identifySvmSpokeInstruction(instruction) {
|
|
|
164
159
|
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([69, 100, 169, 193, 125, 0, 150, 69])), 0)) {
|
|
165
160
|
return SvmSpokeInstruction.SetCurrentTime;
|
|
166
161
|
}
|
|
167
|
-
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([166, 66, 33, 156, 122, 251, 223, 34])), 0)) {
|
|
168
|
-
return SvmSpokeInstruction.SetEnableRoute;
|
|
169
|
-
}
|
|
170
162
|
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47])), 0)) {
|
|
171
163
|
return SvmSpokeInstruction.TransferOwnership;
|
|
172
164
|
}
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
export * from './bridgedToHubPool';
|
|
9
9
|
export * from './claimedRelayerRefund';
|
|
10
10
|
export * from './emergencyDeletedRootBundle';
|
|
11
|
-
export * from './enabledDepositRoute';
|
|
12
11
|
export * from './executedRelayerRefundRoot';
|
|
13
12
|
export * from './filledRelay';
|
|
14
13
|
export * from './fillStatus';
|
|
@@ -24,7 +24,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
__exportStar(require("./bridgedToHubPool"), exports);
|
|
25
25
|
__exportStar(require("./claimedRelayerRefund"), exports);
|
|
26
26
|
__exportStar(require("./emergencyDeletedRootBundle"), exports);
|
|
27
|
-
__exportStar(require("./enabledDepositRoute"), exports);
|
|
28
27
|
__exportStar(require("./executedRelayerRefundRoot"), exports);
|
|
29
28
|
__exportStar(require("./filledRelay"), exports);
|
|
30
29
|
__exportStar(require("./fillStatus"), exports);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AnchorProvider } from "@coral-xyz/anchor";
|
|
1
|
+
import { AnchorProvider, BN } from "@coral-xyz/anchor";
|
|
2
2
|
import { BigNumber } from "@ethersproject/bignumber";
|
|
3
|
+
import { PublicKey } from "@solana/web3.js";
|
|
3
4
|
/**
|
|
4
5
|
* Returns the chainId for a given solana cluster.
|
|
5
6
|
*/
|
|
@@ -8,3 +9,115 @@ export declare const getSolanaChainId: (cluster: "devnet" | "mainnet") => BigNum
|
|
|
8
9
|
* Returns true if the provider is on the devnet cluster.
|
|
9
10
|
*/
|
|
10
11
|
export declare const isSolanaDevnet: (provider: AnchorProvider) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* “Absolute‐deadline” deposit data
|
|
14
|
+
*/
|
|
15
|
+
export declare class DepositSeedData {
|
|
16
|
+
depositor: Uint8Array;
|
|
17
|
+
recipient: Uint8Array;
|
|
18
|
+
inputToken: Uint8Array;
|
|
19
|
+
outputToken: Uint8Array;
|
|
20
|
+
inputAmount: BN;
|
|
21
|
+
outputAmount: BN;
|
|
22
|
+
destinationChainId: BN;
|
|
23
|
+
exclusiveRelayer: Uint8Array;
|
|
24
|
+
quoteTimestamp: BN;
|
|
25
|
+
fillDeadline: BN;
|
|
26
|
+
exclusivityParameter: BN;
|
|
27
|
+
message: Uint8Array;
|
|
28
|
+
constructor(fields: {
|
|
29
|
+
depositor: Uint8Array;
|
|
30
|
+
recipient: Uint8Array;
|
|
31
|
+
inputToken: Uint8Array;
|
|
32
|
+
outputToken: Uint8Array;
|
|
33
|
+
inputAmount: BN;
|
|
34
|
+
outputAmount: BN;
|
|
35
|
+
destinationChainId: BN;
|
|
36
|
+
exclusiveRelayer: Uint8Array;
|
|
37
|
+
quoteTimestamp: BN;
|
|
38
|
+
fillDeadline: BN;
|
|
39
|
+
exclusivityParameter: BN;
|
|
40
|
+
message: Uint8Array;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hash for the standard `deposit(...)` flow
|
|
45
|
+
*/
|
|
46
|
+
export declare function getDepositSeedHash(depositData: {
|
|
47
|
+
depositor: PublicKey;
|
|
48
|
+
recipient: PublicKey;
|
|
49
|
+
inputToken: PublicKey;
|
|
50
|
+
outputToken: PublicKey;
|
|
51
|
+
inputAmount: BN;
|
|
52
|
+
outputAmount: BN;
|
|
53
|
+
destinationChainId: BN;
|
|
54
|
+
exclusiveRelayer: PublicKey;
|
|
55
|
+
quoteTimestamp: BN;
|
|
56
|
+
fillDeadline: BN;
|
|
57
|
+
exclusivityParameter: BN;
|
|
58
|
+
message: Uint8Array;
|
|
59
|
+
}): Uint8Array;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the delegate PDA for `deposit(...)`
|
|
62
|
+
*/
|
|
63
|
+
export declare function getDepositPda(depositData: Parameters<typeof getDepositSeedHash>[0], programId: PublicKey): PublicKey;
|
|
64
|
+
/**
|
|
65
|
+
* “Offset/now” deposit data
|
|
66
|
+
*/
|
|
67
|
+
export declare class DepositNowSeedData {
|
|
68
|
+
depositor: Uint8Array;
|
|
69
|
+
recipient: Uint8Array;
|
|
70
|
+
inputToken: Uint8Array;
|
|
71
|
+
outputToken: Uint8Array;
|
|
72
|
+
inputAmount: BN;
|
|
73
|
+
outputAmount: BN;
|
|
74
|
+
destinationChainId: BN;
|
|
75
|
+
exclusiveRelayer: Uint8Array;
|
|
76
|
+
fillDeadlineOffset: BN;
|
|
77
|
+
exclusivityPeriod: BN;
|
|
78
|
+
message: Uint8Array;
|
|
79
|
+
constructor(fields: {
|
|
80
|
+
depositor: Uint8Array;
|
|
81
|
+
recipient: Uint8Array;
|
|
82
|
+
inputToken: Uint8Array;
|
|
83
|
+
outputToken: Uint8Array;
|
|
84
|
+
inputAmount: BN;
|
|
85
|
+
outputAmount: BN;
|
|
86
|
+
destinationChainId: BN;
|
|
87
|
+
exclusiveRelayer: Uint8Array;
|
|
88
|
+
fillDeadlineOffset: BN;
|
|
89
|
+
exclusivityPeriod: BN;
|
|
90
|
+
message: Uint8Array;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Hash for the `deposit_now(...)` flow
|
|
95
|
+
*/
|
|
96
|
+
export declare function getDepositNowSeedHash(depositData: {
|
|
97
|
+
depositor: PublicKey;
|
|
98
|
+
recipient: PublicKey;
|
|
99
|
+
inputToken: PublicKey;
|
|
100
|
+
outputToken: PublicKey;
|
|
101
|
+
inputAmount: BN;
|
|
102
|
+
outputAmount: BN;
|
|
103
|
+
destinationChainId: BN;
|
|
104
|
+
exclusiveRelayer: PublicKey;
|
|
105
|
+
fillDeadlineOffset: BN;
|
|
106
|
+
exclusivityPeriod: BN;
|
|
107
|
+
message: Uint8Array;
|
|
108
|
+
}): Uint8Array;
|
|
109
|
+
/**
|
|
110
|
+
* Returns the delegate PDA for `deposit_now(...)`
|
|
111
|
+
*/
|
|
112
|
+
export declare function getDepositNowPda(depositData: Parameters<typeof getDepositNowSeedHash>[0], programId: PublicKey): PublicKey;
|
|
113
|
+
/**
|
|
114
|
+
* Returns the fill delegate seed hash.
|
|
115
|
+
*/
|
|
116
|
+
export declare function getFillRelayDelegateSeedHash(relayHash: Uint8Array, repaymentChainId: BN, repaymentAddress: PublicKey): Uint8Array;
|
|
117
|
+
/**
|
|
118
|
+
* Returns the fill delegate PDA.
|
|
119
|
+
*/
|
|
120
|
+
export declare function getFillRelayDelegatePda(relayHash: Uint8Array, repaymentChainId: BN, repaymentAddress: PublicKey, programId: PublicKey): {
|
|
121
|
+
seedHash: Uint8Array;
|
|
122
|
+
pda: PublicKey;
|
|
123
|
+
};
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSolanaDevnet = exports.getSolanaChainId = void 0;
|
|
3
|
+
exports.DepositNowSeedData = exports.DepositSeedData = exports.isSolanaDevnet = exports.getSolanaChainId = void 0;
|
|
4
|
+
exports.getDepositSeedHash = getDepositSeedHash;
|
|
5
|
+
exports.getDepositPda = getDepositPda;
|
|
6
|
+
exports.getDepositNowSeedHash = getDepositNowSeedHash;
|
|
7
|
+
exports.getDepositNowPda = getDepositNowPda;
|
|
8
|
+
exports.getFillRelayDelegateSeedHash = getFillRelayDelegateSeedHash;
|
|
9
|
+
exports.getFillRelayDelegatePda = getFillRelayDelegatePda;
|
|
4
10
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
5
11
|
const ethers_1 = require("ethers");
|
|
12
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
13
|
+
const borsh_1 = require("borsh");
|
|
14
|
+
const utils_1 = require("ethers/lib/utils");
|
|
6
15
|
/**
|
|
7
16
|
* Returns the chainId for a given solana cluster.
|
|
8
17
|
*/
|
|
@@ -23,3 +32,172 @@ const isSolanaDevnet = (provider) => {
|
|
|
23
32
|
throw new Error(`Unsupported solanaCluster endpoint: ${solanaRpcEndpoint}`);
|
|
24
33
|
};
|
|
25
34
|
exports.isSolanaDevnet = isSolanaDevnet;
|
|
35
|
+
/**
|
|
36
|
+
* Generic helper: serialize + keccak256 → 32‑byte Uint8Array
|
|
37
|
+
*/
|
|
38
|
+
function deriveSeedHash(schema, seedObj) {
|
|
39
|
+
const serialized = (0, borsh_1.serialize)(schema, seedObj);
|
|
40
|
+
const hashHex = (0, utils_1.keccak256)(serialized);
|
|
41
|
+
return Buffer.from(hashHex.slice(2), "hex");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* “Absolute‐deadline” deposit data
|
|
45
|
+
*/
|
|
46
|
+
class DepositSeedData {
|
|
47
|
+
constructor(fields) {
|
|
48
|
+
Object.assign(this, fields);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.DepositSeedData = DepositSeedData;
|
|
52
|
+
const depositSeedSchema = new Map([
|
|
53
|
+
[
|
|
54
|
+
DepositSeedData,
|
|
55
|
+
{
|
|
56
|
+
kind: "struct",
|
|
57
|
+
fields: [
|
|
58
|
+
["depositor", [32]],
|
|
59
|
+
["recipient", [32]],
|
|
60
|
+
["inputToken", [32]],
|
|
61
|
+
["outputToken", [32]],
|
|
62
|
+
["inputAmount", "u64"],
|
|
63
|
+
["outputAmount", "u64"],
|
|
64
|
+
["destinationChainId", "u64"],
|
|
65
|
+
["exclusiveRelayer", [32]],
|
|
66
|
+
["quoteTimestamp", "u32"],
|
|
67
|
+
["fillDeadline", "u32"],
|
|
68
|
+
["exclusivityParameter", "u32"],
|
|
69
|
+
["message", ["u8"]],
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
]);
|
|
74
|
+
/**
|
|
75
|
+
* Hash for the standard `deposit(...)` flow
|
|
76
|
+
*/
|
|
77
|
+
function getDepositSeedHash(depositData) {
|
|
78
|
+
const ds = new DepositSeedData({
|
|
79
|
+
depositor: depositData.depositor.toBuffer(),
|
|
80
|
+
recipient: depositData.recipient.toBuffer(),
|
|
81
|
+
inputToken: depositData.inputToken.toBuffer(),
|
|
82
|
+
outputToken: depositData.outputToken.toBuffer(),
|
|
83
|
+
inputAmount: depositData.inputAmount,
|
|
84
|
+
outputAmount: depositData.outputAmount,
|
|
85
|
+
destinationChainId: depositData.destinationChainId,
|
|
86
|
+
exclusiveRelayer: depositData.exclusiveRelayer.toBuffer(),
|
|
87
|
+
quoteTimestamp: depositData.quoteTimestamp,
|
|
88
|
+
fillDeadline: depositData.fillDeadline,
|
|
89
|
+
exclusivityParameter: depositData.exclusivityParameter,
|
|
90
|
+
message: depositData.message,
|
|
91
|
+
});
|
|
92
|
+
return deriveSeedHash(depositSeedSchema, ds);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Returns the delegate PDA for `deposit(...)`
|
|
96
|
+
*/
|
|
97
|
+
function getDepositPda(depositData, programId) {
|
|
98
|
+
const seedHash = getDepositSeedHash(depositData);
|
|
99
|
+
const [pda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("delegate"), seedHash], programId);
|
|
100
|
+
return pda;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* “Offset/now” deposit data
|
|
104
|
+
*/
|
|
105
|
+
class DepositNowSeedData {
|
|
106
|
+
constructor(fields) {
|
|
107
|
+
Object.assign(this, fields);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.DepositNowSeedData = DepositNowSeedData;
|
|
111
|
+
const depositNowSeedSchema = new Map([
|
|
112
|
+
[
|
|
113
|
+
DepositNowSeedData,
|
|
114
|
+
{
|
|
115
|
+
kind: "struct",
|
|
116
|
+
fields: [
|
|
117
|
+
["depositor", [32]],
|
|
118
|
+
["recipient", [32]],
|
|
119
|
+
["inputToken", [32]],
|
|
120
|
+
["outputToken", [32]],
|
|
121
|
+
["inputAmount", "u64"],
|
|
122
|
+
["outputAmount", "u64"],
|
|
123
|
+
["destinationChainId", "u64"],
|
|
124
|
+
["exclusiveRelayer", [32]],
|
|
125
|
+
["fillDeadlineOffset", "u32"],
|
|
126
|
+
["exclusivityPeriod", "u32"],
|
|
127
|
+
["message", ["u8"]],
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
]);
|
|
132
|
+
/**
|
|
133
|
+
* Hash for the `deposit_now(...)` flow
|
|
134
|
+
*/
|
|
135
|
+
function getDepositNowSeedHash(depositData) {
|
|
136
|
+
const dns = new DepositNowSeedData({
|
|
137
|
+
depositor: depositData.depositor.toBuffer(),
|
|
138
|
+
recipient: depositData.recipient.toBuffer(),
|
|
139
|
+
inputToken: depositData.inputToken.toBuffer(),
|
|
140
|
+
outputToken: depositData.outputToken.toBuffer(),
|
|
141
|
+
inputAmount: depositData.inputAmount,
|
|
142
|
+
outputAmount: depositData.outputAmount,
|
|
143
|
+
destinationChainId: depositData.destinationChainId,
|
|
144
|
+
exclusiveRelayer: depositData.exclusiveRelayer.toBuffer(),
|
|
145
|
+
fillDeadlineOffset: depositData.fillDeadlineOffset,
|
|
146
|
+
exclusivityPeriod: depositData.exclusivityPeriod,
|
|
147
|
+
message: depositData.message,
|
|
148
|
+
});
|
|
149
|
+
return deriveSeedHash(depositNowSeedSchema, dns);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Returns the delegate PDA for `deposit_now(...)`
|
|
153
|
+
*/
|
|
154
|
+
function getDepositNowPda(depositData, programId) {
|
|
155
|
+
const seedHash = getDepositNowSeedHash(depositData);
|
|
156
|
+
const [pda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("delegate"), seedHash], programId);
|
|
157
|
+
return pda;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Fill Delegate Seed Data
|
|
161
|
+
*/
|
|
162
|
+
class FillDelegateSeedData {
|
|
163
|
+
constructor(fields) {
|
|
164
|
+
this.relayHash = fields.relayHash;
|
|
165
|
+
this.repaymentChainId = fields.repaymentChainId;
|
|
166
|
+
this.repaymentAddress = fields.repaymentAddress;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Borsh schema for FillDelegateSeedData
|
|
171
|
+
*/
|
|
172
|
+
const fillDelegateSeedSchema = new Map([
|
|
173
|
+
[
|
|
174
|
+
FillDelegateSeedData,
|
|
175
|
+
{
|
|
176
|
+
kind: "struct",
|
|
177
|
+
fields: [
|
|
178
|
+
["relayHash", [32]],
|
|
179
|
+
["repaymentChainId", "u64"],
|
|
180
|
+
["repaymentAddress", [32]],
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
]);
|
|
185
|
+
/**
|
|
186
|
+
* Returns the fill delegate seed hash.
|
|
187
|
+
*/
|
|
188
|
+
function getFillRelayDelegateSeedHash(relayHash, repaymentChainId, repaymentAddress) {
|
|
189
|
+
const ds = new FillDelegateSeedData({
|
|
190
|
+
relayHash,
|
|
191
|
+
repaymentChainId,
|
|
192
|
+
repaymentAddress: repaymentAddress.toBuffer(),
|
|
193
|
+
});
|
|
194
|
+
return deriveSeedHash(fillDelegateSeedSchema, ds);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Returns the fill delegate PDA.
|
|
198
|
+
*/
|
|
199
|
+
function getFillRelayDelegatePda(relayHash, repaymentChainId, repaymentAddress, programId) {
|
|
200
|
+
const seedHash = getFillRelayDelegateSeedHash(relayHash, repaymentChainId, repaymentAddress);
|
|
201
|
+
const [pda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("delegate"), seedHash], programId);
|
|
202
|
+
return { seedHash, pda };
|
|
203
|
+
}
|