Skip to content

Commit

Permalink
feat: add a case to transfer ghostnet tez to etherlink in test-dapp
Browse files Browse the repository at this point in the history
  • Loading branch information
hui-an-yang committed Apr 29, 2024
1 parent a39aaa5 commit 7c0d4a0
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
24 changes: 21 additions & 3 deletions apps/taquito-test-dapp/src/lib/TestContainer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
let loading = false;
let success: boolean | undefined;
let opHash = "";
let input = { text: "", fee: 400, storageLimit: 400, gasLimit: 1320 };
let input = { text: "", fee: 400, storageLimit: 400, gasLimit: 1320, amount: 0, address: "" };
let testResult: { id: string; title: string; body: any };
const run = async () => {
Expand All @@ -28,6 +28,7 @@
test.id === "sign-payload-and-send" ||
test.id === "sign-failingNoop" ||
test.id === "verify-signature" ||
test.id === "transfer-to-etherlink" ||
test.id === "set-transaction-limits"
) {
result = await test.run(input);
Expand Down Expand Up @@ -188,7 +189,7 @@
/* ----------------------------------------------
* Generated by Animista on 2022-4-21 9:31:8
* Licensed under FreeBSD License.
* See http://animista.net/license for more info.
* See http://animista.net/license for more info.
* w: http://animista.net, t: @cssanimista
* ---------------------------------------------- */
Expand Down Expand Up @@ -302,6 +303,19 @@
bind:value={input.text}
/>
</div>
{:else if test.inputRequired && test.inputType === "transfer-to-etherlink"}
<div class="test-input test-transfer-etherlink">
<label for="transfer-address">
<span>Etherlink address</span>
<input type="string" id="etherlink-address" bind:value={input.address} />
</label>
<br />
<br />
<label for="transfer-amount">
<span>amount</span>
<input type="number" id="transfer-amount" bind:value={input.amount} />
</label>
</div>
{:else if test.inputRequired && test.inputType === "set-limits"}
<div class="test-input test-limits">
<label for="set-limit-fee">
Expand Down Expand Up @@ -338,7 +352,11 @@
{#if $store.networkType === NetworkType.CUSTOM}
{shortenHash(opHash)}
{:else}
<a href={`${getTzKtUrl($store.networkType)}/${opHash}`} target="_blank" rel="noopener noreferrer">
<a
href={`${getTzKtUrl($store.networkType)}/${opHash}`}
target="_blank"
rel="noopener noreferrer"
>
{shortenHash(opHash)}
</a>
{/if}
Expand Down
37 changes: 37 additions & 0 deletions apps/taquito-test-dapp/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,25 @@ const verifySignatureWithTaquito = async (
}
};

const transferToEtherlink = async (
amount: number,
address: string,
tezos: TezosToolkit,
): Promise<TestResult> => {
let opHash = "";
try {
const contract = await tezos.wallet.at('KT1VEjeQfDBSfpDH5WeBM5LukHPGM2htYEh3')
let op = await contract.methodsObject.deposit({ evm_address: 'sr18wx6ezkeRjt1SZSeZ2UQzQN3Uc3YLMLqg', l2_address: address }).send({ amount });
await op.confirmation()
opHash = op.hasOwnProperty("opHash") ? op["opHash"] : op["hash"];
console.log("Operation successful with op hash:", opHash);
return { success: true, opHash };
} catch (error) {
console.log(error);
return { success: false, opHash: "" };
}
};

const setTransactionLimits = async (
contract: ContractAbstraction<Wallet> | ContractAbstraction<ContractProvider>,
fee: string,
Expand Down Expand Up @@ -727,6 +746,24 @@ export const init = (
inputType: "string",
lastResult: { option: "none", val: false }
},
{
id: "transfer-to-etherlink",
name: "Transfer tez from ghostnet to Etherlink",
description:
"This test allows you transfer your tez from ghostnet to etherlink",
documentation: '',
keyword: 'transfer to etherlink',
run: input =>
transferToEtherlink(
input.amount,
input.address,
Tezos
),
showExecutionTime: false,
inputRequired: true,
inputType: "transfer-to-etherlink",
lastResult: { option: "none", val: false }
},
{
id: "set-transaction-limits",
name: "Set the transaction limits",
Expand Down
2 changes: 1 addition & 1 deletion apps/taquito-test-dapp/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface TestSettings {
run: (input?: any) => Promise<TestResult>;
showExecutionTime: boolean;
inputRequired: boolean;
inputType?: "string" | "set-limits" | "sapling";
inputType?: "string" | "set-limits" | "sapling" | "transfer-to-etherlink";
lastResult: { option: "none" | "some"; val: boolean };
}

Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"edsk",
"Ejara",
"entrypoints",
"etherlink",
"eztz",
"FAILWITH",
"flextesa",
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"example:scan-path-ledger": "node -r ts-node/register --preserve-symlinks scan-path-ledger.ts"
},
"dependencies": {
"@ledgerhq/hw-transport-node-hid": "^6.27.21",
"@ledgerhq/hw-transport-node-hid": "^6.28.5",
"@taquito/ledger-signer": "^19.2.0",
"@taquito/local-forging": "^19.2.0",
"@taquito/michel-codec": "^19.2.0",
Expand Down

0 comments on commit 7c0d4a0

Please sign in to comment.