From 0e16d0c6d528118ca744992664fcab7ae790a30a Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Tue, 26 Sep 2023 15:45:39 +0200 Subject: [PATCH] :recycle: Code refactor --- Anchor.toml | 2 +- client/sdk/src/idl/tens.ts | 580 +++++++++++++++++++------------------ 2 files changed, 303 insertions(+), 279 deletions(-) diff --git a/Anchor.toml b/Anchor.toml index 6dd681e..af37bb2 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -18,7 +18,7 @@ url = "https://api.apr.dev" [provider] cluster = "localnet" -wallet = "client/tests/fixtures/provider" +wallet = "client/tests/fixtures/provider.json" [scripts] test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 client/tests/*" diff --git a/client/sdk/src/idl/tens.ts b/client/sdk/src/idl/tens.ts index 58bd267..b3ce2a1 100644 --- a/client/sdk/src/idl/tens.ts +++ b/client/sdk/src/idl/tens.ts @@ -1,433 +1,457 @@ -export interface Tens { - version: "0.1.0"; - name: "tens"; - instructions: [ +export type Tens = { + "version": "0.1.0", + "name": "tens", + "instructions": [ { - name: "register"; - accounts: [ + "name": "register", + "accounts": [ { - name: "signer"; - isMut: true; - isSigner: true; + "name": "signer", + "isMut": true, + "isSigner": true }, { - name: "tensState"; - isMut: true; - isSigner: false; + "name": "tensState", + "isMut": true, + "isSigner": false }, { - name: "systemProgram"; - isMut: false; - isSigner: false; + "name": "systemProgram", + "isMut": false, + "isSigner": false } - ]; - args: [ + ], + "args": [ { - name: "soarState"; - type: "publicKey"; + "name": "soarState", + "type": "publicKey" }, { - name: "soarLeaderboard"; - type: "publicKey"; + "name": "soarLeaderboard", + "type": "publicKey" }, { - name: "soarLeaderboardTopEntries"; - type: "publicKey"; + "name": "soarLeaderboardTopEntries", + "type": "publicKey" } - ]; + ] }, { - name: "makeMove"; - accounts: [ + "name": "makeMove", + "accounts": [ { - name: "user"; - isMut: true; - isSigner: true; + "name": "user", + "isMut": true, + "isSigner": true }, { - name: "tensState"; - isMut: true; - isSigner: false; + "name": "tensState", + "isMut": true, + "isSigner": false }, { - name: "soarState"; - isMut: false; - isSigner: false; + "name": "soarState", + "isMut": false, + "isSigner": false }, { - name: "soarLeaderboard"; - isMut: false; - isSigner: false; + "name": "soarLeaderboard", + "isMut": false, + "isSigner": false }, { - name: "soarPlayerAccount"; - isMut: false; - isSigner: false; + "name": "soarPlayerAccount", + "isMut": false, + "isSigner": false }, { - name: "soarPlayerScores"; - isMut: true; - isSigner: false; + "name": "soarPlayerScores", + "isMut": true, + "isSigner": false }, { - name: "soarTopEntries"; - isMut: true; - isSigner: false; - isOptional: true; + "name": "soarTopEntries", + "isMut": true, + "isSigner": false, + "isOptional": true }, { - name: "soarProgram"; - isMut: false; - isSigner: false; + "name": "soarProgram", + "isMut": false, + "isSigner": false }, { - name: "systemProgram"; - isMut: false; - isSigner: false; + "name": "systemProgram", + "isMut": false, + "isSigner": false } - ]; - args: []; + ], + "args": [] }, { - name: "claimReward"; - accounts: [ + "name": "claimReward", + "accounts": [ { - name: "user"; - isMut: true; - isSigner: true; + "name": "user", + "isMut": true, + "isSigner": true }, { - name: "tensState"; - isMut: true; - isSigner: false; + "name": "tensState", + "isMut": true, + "isSigner": false }, { - name: "playerAccount"; - isMut: true; - isSigner: false; + "name": "playerAccount", + "isMut": true, + "isSigner": false }, { - name: "soarPlayerScores"; - isMut: false; - isSigner: false; + "name": "soarPlayerScores", + "isMut": false, + "isSigner": false }, { - name: "soarTopEntries"; - isMut: false; - isSigner: false; + "name": "soarTopEntries", + "isMut": false, + "isSigner": false }, { - name: "soarState"; - isMut: false; - isSigner: false; + "name": "soarState", + "isMut": false, + "isSigner": false }, { - name: "soarAchievement"; - isMut: false; - isSigner: false; + "name": "soarAchievement", + "isMut": false, + "isSigner": false }, { - name: "soarReward"; - isMut: true; - isSigner: false; + "name": "soarReward", + "isMut": true, + "isSigner": false }, { - name: "soarPlayerAchievement"; - isMut: true; - isSigner: false; + "name": "soarPlayerAchievement", + "isMut": true, + "isSigner": false }, { - name: "sourceTokenAccount"; - isMut: true; - isSigner: false; + "name": "sourceTokenAccount", + "isMut": true, + "isSigner": false }, { - name: "userTokenAccount"; - isMut: true; - isSigner: false; + "name": "userTokenAccount", + "isMut": true, + "isSigner": false }, { - name: "tokenProgram"; - isMut: false; - isSigner: false; + "name": "tokenProgram", + "isMut": false, + "isSigner": false }, { - name: "systemProgram"; - isMut: false; - isSigner: false; + "name": "systemProgram", + "isMut": false, + "isSigner": false }, { - name: "soarProgram"; - isMut: false; - isSigner: false; + "name": "soarProgram", + "isMut": false, + "isSigner": false } - ]; - args: []; + ], + "args": [] } - ]; - accounts: [ + ], + "accounts": [ { - name: "tens"; - docs: ["A simple game."]; - type: { - kind: "struct"; - fields: [ + "name": "tens", + "docs": [ + "A simple game." + ], + "type": { + "kind": "struct", + "fields": [ { - name: "counter"; - docs: ["The game counter."]; - type: "u64"; + "name": "counter", + "docs": [ + "The game counter." + ], + "type": "u64" }, { - name: "soar"; - docs: ["The SOAR keys for this program."]; - type: { - defined: "SoarKeysStorage"; - }; + "name": "soar", + "docs": [ + "The SOAR keys for this program." + ], + "type": { + "defined": "SoarKeysStorage" + } } - ]; - }; + ] + } } - ]; - types: [ + ], + "types": [ { - name: "SoarKeysStorage"; - type: { - kind: "struct"; - fields: [ + "name": "SoarKeysStorage", + "type": { + "kind": "struct", + "fields": [ { - name: "state"; - docs: ["The soar state for this game."]; - type: "publicKey"; + "name": "state", + "docs": [ + "The soar state for this game." + ], + "type": "publicKey" }, { - name: "leaderboard"; - docs: ["The soar leaderboard for this game."]; - type: "publicKey"; + "name": "leaderboard", + "docs": [ + "The soar leaderboard for this game." + ], + "type": "publicKey" }, { - name: "topEntries"; - docs: ["The soar top-entries account for this game."]; - type: "publicKey"; + "name": "topEntries", + "docs": [ + "The soar top-entries account for this game." + ], + "type": "publicKey" } - ]; - }; + ] + } } - ]; -} + ] +}; export const IDL: Tens = { - version: "0.1.0", - name: "tens", - instructions: [ + "version": "0.1.0", + "name": "tens", + "instructions": [ { - name: "register", - accounts: [ + "name": "register", + "accounts": [ { - name: "signer", - isMut: true, - isSigner: true, + "name": "signer", + "isMut": true, + "isSigner": true }, { - name: "tensState", - isMut: true, - isSigner: false, + "name": "tensState", + "isMut": true, + "isSigner": false }, { - name: "systemProgram", - isMut: false, - isSigner: false, - }, + "name": "systemProgram", + "isMut": false, + "isSigner": false + } ], - args: [ + "args": [ { - name: "soarState", - type: "publicKey", + "name": "soarState", + "type": "publicKey" }, { - name: "soarLeaderboard", - type: "publicKey", + "name": "soarLeaderboard", + "type": "publicKey" }, { - name: "soarLeaderboardTopEntries", - type: "publicKey", - }, - ], + "name": "soarLeaderboardTopEntries", + "type": "publicKey" + } + ] }, { - name: "makeMove", - accounts: [ + "name": "makeMove", + "accounts": [ { - name: "user", - isMut: true, - isSigner: true, + "name": "user", + "isMut": true, + "isSigner": true }, { - name: "tensState", - isMut: true, - isSigner: false, + "name": "tensState", + "isMut": true, + "isSigner": false }, { - name: "soarState", - isMut: false, - isSigner: false, + "name": "soarState", + "isMut": false, + "isSigner": false }, { - name: "soarLeaderboard", - isMut: false, - isSigner: false, + "name": "soarLeaderboard", + "isMut": false, + "isSigner": false }, { - name: "soarPlayerAccount", - isMut: false, - isSigner: false, + "name": "soarPlayerAccount", + "isMut": false, + "isSigner": false }, { - name: "soarPlayerScores", - isMut: true, - isSigner: false, + "name": "soarPlayerScores", + "isMut": true, + "isSigner": false }, { - name: "soarTopEntries", - isMut: true, - isSigner: false, - isOptional: true, + "name": "soarTopEntries", + "isMut": true, + "isSigner": false, + "isOptional": true }, { - name: "soarProgram", - isMut: false, - isSigner: false, + "name": "soarProgram", + "isMut": false, + "isSigner": false }, { - name: "systemProgram", - isMut: false, - isSigner: false, - }, + "name": "systemProgram", + "isMut": false, + "isSigner": false + } ], - args: [], + "args": [] }, { - name: "claimReward", - accounts: [ + "name": "claimReward", + "accounts": [ { - name: "user", - isMut: true, - isSigner: true, + "name": "user", + "isMut": true, + "isSigner": true }, { - name: "tensState", - isMut: true, - isSigner: false, + "name": "tensState", + "isMut": true, + "isSigner": false }, { - name: "playerAccount", - isMut: true, - isSigner: false, + "name": "playerAccount", + "isMut": true, + "isSigner": false }, { - name: "soarPlayerScores", - isMut: false, - isSigner: false, + "name": "soarPlayerScores", + "isMut": false, + "isSigner": false }, { - name: "soarTopEntries", - isMut: false, - isSigner: false, + "name": "soarTopEntries", + "isMut": false, + "isSigner": false }, { - name: "soarState", - isMut: false, - isSigner: false, + "name": "soarState", + "isMut": false, + "isSigner": false }, { - name: "soarAchievement", - isMut: false, - isSigner: false, + "name": "soarAchievement", + "isMut": false, + "isSigner": false }, { - name: "soarReward", - isMut: true, - isSigner: false, + "name": "soarReward", + "isMut": true, + "isSigner": false }, { - name: "soarPlayerAchievement", - isMut: true, - isSigner: false, + "name": "soarPlayerAchievement", + "isMut": true, + "isSigner": false }, { - name: "sourceTokenAccount", - isMut: true, - isSigner: false, + "name": "sourceTokenAccount", + "isMut": true, + "isSigner": false }, { - name: "userTokenAccount", - isMut: true, - isSigner: false, + "name": "userTokenAccount", + "isMut": true, + "isSigner": false }, { - name: "tokenProgram", - isMut: false, - isSigner: false, + "name": "tokenProgram", + "isMut": false, + "isSigner": false }, { - name: "systemProgram", - isMut: false, - isSigner: false, + "name": "systemProgram", + "isMut": false, + "isSigner": false }, { - name: "soarProgram", - isMut: false, - isSigner: false, - }, + "name": "soarProgram", + "isMut": false, + "isSigner": false + } ], - args: [], - }, + "args": [] + } ], - accounts: [ + "accounts": [ { - name: "tens", - docs: ["A simple game."], - type: { - kind: "struct", - fields: [ + "name": "tens", + "docs": [ + "A simple game." + ], + "type": { + "kind": "struct", + "fields": [ { - name: "counter", - docs: ["The game counter."], - type: "u64", + "name": "counter", + "docs": [ + "The game counter." + ], + "type": "u64" }, { - name: "soar", - docs: ["The SOAR keys for this program."], - type: { - defined: "SoarKeysStorage", - }, - }, - ], - }, - }, + "name": "soar", + "docs": [ + "The SOAR keys for this program." + ], + "type": { + "defined": "SoarKeysStorage" + } + } + ] + } + } ], - types: [ + "types": [ { - name: "SoarKeysStorage", - type: { - kind: "struct", - fields: [ + "name": "SoarKeysStorage", + "type": { + "kind": "struct", + "fields": [ { - name: "state", - docs: ["The soar state for this game."], - type: "publicKey", + "name": "state", + "docs": [ + "The soar state for this game." + ], + "type": "publicKey" }, { - name: "leaderboard", - docs: ["The soar leaderboard for this game."], - type: "publicKey", + "name": "leaderboard", + "docs": [ + "The soar leaderboard for this game." + ], + "type": "publicKey" }, { - name: "topEntries", - docs: ["The soar top-entries account for this game."], - type: "publicKey", - }, - ], - }, - }, - ], + "name": "topEntries", + "docs": [ + "The soar top-entries account for this game." + ], + "type": "publicKey" + } + ] + } + } + ] };