Skip to content

Commit 70d82df

Browse files
authored
feat(svm): fix simple fill script (#898)
* feat(svm): fix simple fill script Signed-off-by: Pablo Maldonado <pablo@umaproject.org> * feat: simplify Signed-off-by: Pablo Maldonado <pablo@umaproject.org> * feat: bump version Signed-off-by: Pablo Maldonado <pablo@umaproject.org> --------- Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
1 parent 8ef0a3a commit 70d82df

File tree

3 files changed

+52
-18
lines changed

3 files changed

+52
-18
lines changed

deployments/deployments.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,23 @@
183183
"1301": {
184184
"SpokePool": { "address": "0x6999526e507Cc3b03b180BbE05E1Ff938259A874", "blockNumber": 12593713 },
185185
"MulticallHandler": { "address": "0x924a9f036260DdD5808007E1AA95f08eD08aA569", "blockNumber": 12594561 }
186+
},
187+
"133268194659241": {
188+
"SvmSpoke": {
189+
"address": "JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq",
190+
"blockNumber": 356313770
191+
},
192+
"MulticallHandler": {
193+
"address": "Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h",
194+
"blockNumber": 356321050
195+
},
196+
"MessageTransmitter": {
197+
"address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd",
198+
"blockNumber": 339604856
199+
},
200+
"TokenMessengerMinter": {
201+
"address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3",
202+
"blockNumber": 277864039
203+
}
186204
}
187205
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@across-protocol/contracts",
3-
"version": "4.0.2",
3+
"version": "4.0.3",
44
"author": "UMA Team",
55
"license": "AGPL-3.0-only",
66
"repository": {

scripts/svm/simpleFill.ts

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { PublicKey, SystemProgram, Transaction, sendAndConfirmTransaction } from
1515
import yargs from "yargs";
1616
import { hideBin } from "yargs/helpers";
1717
import { calculateRelayHashUint8Array, getSpokePoolProgram, intToU8Array32 } from "../../src/svm/web3-v1";
18+
import { FillDataValues } from "../../src/types/svm";
1819

1920
// Set up the provider
2021
const provider = AnchorProvider.env();
@@ -133,6 +134,16 @@ async function fillRelay(): Promise<void> {
133134

134135
const tokenDecimals = (await getMint(provider.connection, outputToken, undefined, TOKEN_PROGRAM_ID)).decimals;
135136

137+
// Create the ATA using the create_token_accounts method
138+
const createTokenAccountsIx = await program.methods
139+
.createTokenAccounts()
140+
.accounts({ signer: signer.publicKey, mint: outputToken, tokenProgram: TOKEN_PROGRAM_ID })
141+
.remainingAccounts([
142+
{ pubkey: recipient, isWritable: false, isSigner: false },
143+
{ pubkey: recipientTokenAccount, isWritable: true, isSigner: false },
144+
])
145+
.instruction();
146+
136147
// Delegate state PDA to pull relayer tokens.
137148
const approveIx = await createApproveCheckedInstruction(
138149
relayerTokenAccount,
@@ -145,24 +156,29 @@ async function fillRelay(): Promise<void> {
145156
TOKEN_PROGRAM_ID
146157
);
147158

148-
const fillIx = await (
149-
program.methods.fillRelay(Array.from(relayHashUint8Array), relayData, chainId, signer.publicKey) as any
150-
)
151-
.accounts({
152-
state: statePda,
153-
signer: signer.publicKey,
154-
instructionParams: program.programId,
155-
mint: outputToken,
156-
relayerTokenAccount: relayerTokenAccount,
157-
recipientTokenAccount: recipientTokenAccount,
158-
fillStatus: fillStatusPda,
159-
tokenProgram: TOKEN_PROGRAM_ID,
160-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
161-
systemProgram: SystemProgram.programId,
162-
programId: programId,
163-
})
159+
const fillDataValues: FillDataValues = [Array.from(relayHashUint8Array), relayData, chainId, signer.publicKey];
160+
161+
const fillAccounts = {
162+
state: statePda,
163+
signer: signer.publicKey,
164+
instructionParams: program.programId,
165+
mint: outputToken,
166+
relayerTokenAccount: relayerTokenAccount,
167+
recipientTokenAccount: recipientTokenAccount,
168+
fillStatus: fillStatusPda,
169+
tokenProgram: TOKEN_PROGRAM_ID,
170+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
171+
systemProgram: SystemProgram.programId,
172+
programId: programId,
173+
program: program.programId,
174+
};
175+
176+
const fillIx = await program.methods
177+
.fillRelay(...fillDataValues)
178+
.accounts(fillAccounts)
164179
.instruction();
165-
const fillTx = new Transaction().add(approveIx, fillIx);
180+
181+
const fillTx = new Transaction().add(createTokenAccountsIx, approveIx, fillIx);
166182
const tx = await sendAndConfirmTransaction(provider.connection, fillTx, [signer]);
167183

168184
console.log("Transaction signature:", tx);

0 commit comments

Comments
 (0)