near-daos / sputnik-dao-contract

Smart contracts for https://app.astrodao.com
https://astrodao.com/
MIT License
107 stars 79 forks source link

the account ID is invalid #173

Closed GaloisField2718 closed 2 years ago

GaloisField2718 commented 2 years ago

In the step 6 in the main README.

 near call $CONTRACT_ID create "{\"name\": \"genesisDAO\", \"args\": \"$ARGS\"}" --accountId $CONTRACT_ID --amount 10 --gas 150000000000000

ExecutionError: Smart contract panicked: panicked at 'Failed to deserialize input from JSON.: Error("the account ID is invalid", line: 1, column: 20)', sputnikdao-factory2/src/lib.rs:49:1

Failure [marseille.testnet]: Error: {"index":0,"kind":{"ExecutionError":"Smart contract panicked: panicked at 'Failed to deserialize input from JSON.: Error(\"the account ID is invalid\", line: 1, column: 20)', sputnikdao-factory2/src/lib.rs:49:1"}} ServerTransactionError: {"index":0,"kind":{"ExecutionError":"Smart contract panicked: panicked at 'Failed to deserialize input from JSON.: Error(\"the account ID is invalid\", line: 1, column: 20)', sputnikdao-factory2/src/lib.rs:49:1"}} at Object.parseResultError (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/utils/rpc_errors.js:31:29) at Account.signAndSendTransactionV2 (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:160:36) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async scheduleFunctionCall (/usr/local/lib/node_modules/near-cli/commands/call.js:57:38) at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) { type: 'FunctionCallError', context: undefined, index: 0, kind: { ExecutionError: Smart contract panicked: panicked at 'Failed to deserialize input from JSON.: Error("the account ID is invalid", line: 1, column: 20)', sputnikdao-factory2/src/lib.rs:49:1 }, transaction_outcome: { block_hash: 'A2DNdTZgCbHX1GowfeqDjZJpMeftGjsWuknTGs8QtKj4', id: '5PTrtmngBUzkecFP6cmAYjeYuFyVmVzkcWJKhKPQ1vHu', outcome: { executor_id: 'marseille.testnet', gas_burnt: 2428459860094, logs: [], metadata: [Object], receipt_ids: [Array], status: [Object], tokens_burnt: '242845986009400000000' }, proof: [ [Object], [Object], [Object] ] } }

I put

export COUNCIL='["marseille.testnet", "marseille1.testnet"]'

And

export ARGS=`echo '{"config": {"name": "genesisDAO", "purpose": "It is THE Genesis DAO", "metadata": "Metadatas"}, "policy": '$COUNCIL'}' | base64`

I don't understand because the two address : "marseille.testnet", "marseille1.testnet" is valid, and it's the same error if I put as in example council-member.testnet, marseille.testnet

GaloisField2718 commented 2 years ago

I had tried with another account and it is the same problem. This time I used the README of sputnikdao-factory2 but it's the same error Smart contract panicked: panicked at 'Failed to deserialize input from JSON.: Error("the account ID is invalid", line: 1, column: 20)', sputnikdao-factory2/src/lib.rs:49:1. If it helps I can put complete error.

GaloisField2718 commented 2 years ago

Moreover the command :

near view marseille.testnet get_dao_list

return this error :

View call: marseille.testnet.get_dao_list() An error occured Error: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: "panicked at 'Cannot deserialize the contract state.: Custom { kind: InvalidData, error: \"Not all bytes read\" }', /Users/galoisfield/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-4.0.0-pre.7/src/environment/env.rs:688:46" })). { "block_hash": "9R9A5czcVFqD63kXovw3XKEgH6EYN2S35qiv4kyRrWRW", "block_height": 89083343, "error": "wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: \"panicked at 'Cannot deserialize the contract state.: Custom { kind: InvalidData, error: \\"Not all bytes read\\" }', /Users/galoisfield/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-4.0.0-pre.7/src/environment/env.rs:688:46\" }))", "logs": [] } at JsonRpcProvider.query (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/providers/json-rpc-provider.js:123:19) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Account.viewFunction (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:366:24) at async exports.callViewFunction (/usr/local/lib/node_modules/near-cli/index.js:94:48) at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) TypedError: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: "panicked at 'Cannot deserialize the contract state.: Custom { kind: InvalidData, error: \"Not all bytes read\" }', /Users/galoisfield/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-4.0.0-pre.7/src/environment/env.rs:688:46" })). { "block_hash": "9R9A5czcVFqD63kXovw3XKEgH6EYN2S35qiv4kyRrWRW", "block_height": 89083343, "error": "wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: \"panicked at 'Cannot deserialize the contract state.: Custom { kind: InvalidData, error: \\"Not all bytes read\\" }', /Users/galoisfield/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-4.0.0-pre.7/src/environment/env.rs:688:46\" }))", "logs": [] } at JsonRpcProvider.query (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/providers/json-rpc-provider.js:123:19) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Account.viewFunction (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:366:24) at async exports.callViewFunction (/usr/local/lib/node_modules/near-cli/index.js:94:48) at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) { type: 'UntypedError', context: undefined }

I don't understand why with anank1.testnet I have an empty list (logic, because creation transaction hadn't work) and here I have this error.

HxSimo commented 2 years ago

Try to put all names in full lowercase

GaloisField2718 commented 2 years ago

It's the same output.... Failure [anank2.testnet]: Error: {"index":3,"kind":{"ExecutionError":"Smart contract panicked: panicked at 'Failed to deserialize input from JSON.: Error(\"Encoded text cannot have a 6-bit remainder.\", line: 1, column: 94)', sputnikdao2/src/lib.rs:83:1"}} ServerTransactionError: {"index":3,"kind":{"ExecutionError":"Smart contract panicked: panicked at 'Failed to deserialize input from JSON.: Error(\"Encoded text cannot have a 6-bit remainder.\", line: 1, column: 94)', sputnikdao2/src/lib.rs:83:1"}} at Object.parseResultError (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/utils/rpc_errors.js:31:29) at Account.signAndSendTransactionV2 (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:160:36) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async scheduleFunctionCall (/usr/local/lib/node_modules/near-cli/commands/call.js:57:38) at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) { type: 'FunctionCallError', context: undefined, index: 3, kind: { ExecutionError: Smart contract panicked: panicked at 'Failed to deserialize input from JSON.: Error("Encoded text cannot have a 6-bit remainder.", line: 1, column: 94)', sputnikdao2/src/lib.rs:83:1 }, transaction_outcome: { block_hash: 'HVefNWZuh8PVKpMkBrEnpmtXmmDu1RBrZwZ2GaMmrBXT', id: '9mUQVZUASPWvZx5CYQk8i4ZdRt8WBvWAtqvs5StmniCZ', outcome: { executor_id: 'anank2.testnet', gas_burnt: 2428551533388, logs: [], metadata: [Object], receipt_ids: [Array], status: [Object], tokens_burnt: '242855153338800000000' }, proof: [ [Object], [Object] ] }

It's this error 'Error("Encoded text cannot have a 6-bit remainder.", line: 1, column: 94)' that I don't understand.

And inside this file sputnikdao2/src/lib.rs:83:1 I found nothing

HxSimo commented 2 years ago

What's your output in base64 ?

GaloisField2718 commented 2 years ago

With full lower case : eyJjb25maWciOiB7Im5hbWUiOiAiZ2VuZXNpc2RhbyIsICJwdXJwb3NlIjogIml0IGlzIHRoZSBnZW5lc2lzIGRhbyIsICJtZXRhZGF0YSI6ICJtZXRhZGF0YXMifSwgInBvbGljeSI6IFsibWFyc2VpbGxlLnRlc3RuZXQiLCAibWFyc2VpbGxlMS50ZXN0bmV0IiwiYW5hbmsxLnRlc3RuZXQiLCJhbmFuazIudGVzdG5ldCJdfQo= With regular case like my first post : eyJjb25maWciOiB7Im5hbWUiOiAiZ2VuZXNpc0RBTyIsICJwdXJwb3NlIjogIkl0IGlzIFRIRSBHZW5lc2lzIERBTyIsICJtZXRhZGF0YSI6ICJNZXRhZGF0YXMifSwgInBvbGljeSI6IFsibWFyc2VpbGxlLnRlc3RuZXQiLCAibWFyc2VpbGxlMS50ZXN0bmV0IiwiYW5hbmsxLnRlc3RuZXQiLCJhbmFuazIudGVzdG5ldCJdfQo=

It seems to be the same... it's weird no ?

GaloisField2718 commented 2 years ago

I try without transforming in base64 but this doesn't work With this command set : ./build.sh; export CONTRACT_ID=anank2.testnet; near deploy $CONTRACT_ID --wasmFile=res/sputnikdao_factory2.wasm --accountId $CONTRACT_ID; export COUNCIL='["marseille.testnet", "marseille1.testnet","anank1.testnet","anank2.testnet"]'; export ARGS=echo '{"config": {"name": "genesis", "purpose": "It is THE Genesis DAO", "metadata": "Metadatas"}, "policy": '$COUNCIL'}'; near call $CONTRACT_ID create "{\"name\": \"genesis\", \"args\": \"$ARGS\"}" --accountId anank2.testnet --amount 10 --gas 150000000000000;

Return : Starting deployment. Account id: anank2.testnet, node: https://rpc.testnet.near.org, helper: https://helper.testnet.near.org, file: res/sputnikdao_factory2.wasm Transaction Id 46VazbeRaBMKG47hJKMff57Fi1ZCxLeMoyE9s1Bbs2i1 To see the transaction in the transaction explorer, please open this url in your browser https://explorer.testnet.near.org/transactions/46VazbeRaBMKG47hJKMff57Fi1ZCxLeMoyE9s1Bbs2i1 Done deploying to anank2.testnet Scheduling a call: anank2.testnet.create({"name": "genesis", "args": "{"config": {"name": "genesis", "purpose": "It is THE Genesis DAO", "metadata": "Metadatas"}, "policy": ["marseille.testnet", "marseille1.testnet","anank1.testnet","anank2.testnet"]}"}) with attached 10 NEAR An error occured SyntaxError: Unexpected token c in JSON at position 31 at JSON.parse () at scheduleFunctionCall (/usr/local/lib/node_modules/near-cli/commands/call.js:54:84) at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) SyntaxError: Unexpected token c in JSON at position 31 at JSON.parse () at scheduleFunctionCall (/usr/local/lib/node_modules/near-cli/commands/call.js:54:84) at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9)

GaloisField2718 commented 2 years ago

And a specifity on the README is to note echo... between this symbol `

GaloisField2718 commented 2 years ago

I think the problem is linked with the file call.js : /usr/local/lib/node_modules/near-cli/commands/call.js

How can I try function inside call.js ?

Because I think this code : const parsedArgs = options.base64 ? Buffer.from(options.args, 'base64') : JSON.parse(options.args || '{}'); console.log('Doing account.functionCall()'); try { const functionCallResponse = await account.functionCall({ contractId: options.contractName, methodName: options.methodName, args: parsedArgs, gas: options.gas, attachedDeposit: deposit, }); can be a part of problem

GaloisField2718 commented 2 years ago

do echo $ARGS and send it here

I did previously but it's this : eyJjb25maWciOiB7Im5hbWUiOiAiZ2VuZXNpc2RhbyIsICJwdXJwb3NlIjogIml0IGlzIHRoZSBnZW5lc2lzIGRhbyIsICJtZXRhZGF0YSI6ICJtZXRhZGF0YXMifSwgInBvbGljeSI6IFsiYW5hbmsyLnRlc3RuZXQiLCJtYXJzZWlsbGUudGVzdG5ldCJdfQo=

HxSimo commented 2 years ago

Okey so now try like this {"config": {"name": "genesisdao", "purpose": "it is the genesis dao", "metadata": ""}, "policy": ["marseille.testnet", "marseille1.testnet","anank1.testnet","anank2.testnet"]}

GaloisField2718 commented 2 years ago

It's this issue : Starting deployment. Account id: anank2.testnet, node: https://rpc.testnet.near.org/, helper: https://helper.testnet.near.org/, file: res/sputnikdao_factory2.wasm Transaction Id 46VazbeRaBMKG47hJKMff57Fi1ZCxLeMoyE9s1Bbs2i1 To see the transaction in the transaction explorer, please open this url in your browser https://explorer.testnet.near.org/transactions/46VazbeRaBMKG47hJKMff57Fi1ZCxLeMoyE9s1Bbs2i1 Done deploying to anank2.testnet Scheduling a call: anank2.testnet.create({"name": "genesis", "args": "{"config": {"name": "genesis", "purpose": "It is THE Genesis DAO", "metadata": "Metadatas"}, "policy": ["marseille.testnet", "marseille1.testnet","anank1.testnet","anank2.testnet"]}"}) with attached 10 NEAR An error occured SyntaxError: Unexpected token c in JSON at position 31 at JSON.parse () at scheduleFunctionCall (/usr/local/lib/node_modules/near-cli/commands/call.js:54:84) at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) SyntaxError: Unexpected token c in JSON at position 31 at JSON.parse () at scheduleFunctionCall (/usr/local/lib/node_modules/near-cli/commands/call.js:54:84) at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9)

HxSimo commented 2 years ago

https://github.com/near-daos/sputnik-dao-contract/issues/173#issuecomment-1121285347

GaloisField2718 commented 2 years ago

I try : export ARGS =echo '{"config": {"name": "genesisdao", "purpose": "it is the genesis dao", "metadata": ""}, "policy": ["marseille.testnet", "marseille1.testnet","anank1.testnet","anank2.testnet"]}'` ?

HxSimo commented 2 years ago

yes try this export ARGS=`echo '{"config": {"name": "genesisdao", "purpose": "it is the genesis dao", "metadata": ""}, "policy": ["marseille.testnet", "marseille1.testnet","anank1.testnet","anank2.testnet"]}' | base64`

GaloisField2718 commented 2 years ago

It tells me bad assignment

GaloisField2718 commented 2 years ago

yes try this export ARGS=`echo '{"config": {"name": "genesisdao", "purpose": "it is the genesis dao", "metadata": ""}, "policy": ["marseille.testnet", "marseille1.testnet","anank1.testnet","anank2.testnet"]}' | base64`

Waaaaaaa !!! It's working !!!!

GaloisField2718 commented 2 years ago

Thank you so much !! What was wrong ??

HxSimo commented 2 years ago

I try : export ARGS =echo '{"config": {"name": "genesisdao", "purpose": "it is the genesis dao", "metadata": ""}, "policy": ["marseille.testnet", "marseille1.testnet","anank1.testnet","anank2.testnet"]}'` ?

You need write export ARGS=`echo ... without spaces, in metadata, "Metadatas" wasn't a good input, and your name need to be in lowercase

GaloisField2718 commented 2 years ago

aw okay ! And just a question where can I find good infos to put inside metadatas ?

GaloisField2718 commented 2 years ago

THANK YOU THANK YOU THANK YOU 🙏 @ClementMoyal