Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue using getAccountAddress #234

Closed
Luze26 opened this issue May 23, 2024 · 8 comments · Fixed by #237
Closed

Issue using getAccountAddress #234

Luze26 opened this issue May 23, 2024 · 8 comments · Fixed by #237
Assignees
Labels
bug Something isn't working

Comments

@Luze26
Copy link

Luze26 commented May 23, 2024

When using flow-js-testing 0.6.0-stable-cadence.3 and the CLI v1.15.0-cadence-v1.0.0-preview.13.

When I run:

await getAccountAddress("Alice");

I get the following error:

Signatures TypeError: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object
        at new NodeError (node:internal/errors:405:5)
        at Function.from (node:buffer:325:9)
        at hashAlgorithm (/tests/node_modules/@onflow/flow-js-testing/src/crypto.js:141:43)
        at Object.signingFunction (/tests/node_modules/@onflow/flow-js-testing/src/crypto.js:191:6)
        at signingFunction (/tests/node_modules/@onflow/sdk/src/resolve/resolve-signatures.ts:59:36)
        at Array.map (<anonymous>)
        at map (/tests/node_modules/@onflow/sdk/src/resolve/resolve-signatures.ts:46:40)
        at processTicksAndRejections (node:internal/process/task_queues:95:5)
        at recPipe (/tests/node_modules/@onflow/sdk/src/interaction/interaction.ts:333:19) {
      code: 'ERR_INVALID_ARG_TYPE'
    } {
      ix: {
        tag: 'TRANSACTION',
        assigns: { 'ix.cadence': [Function (anonymous)] },
        status: 'OK',
        reason: null,
        accounts: { '0xf8d6e0586b0a20c7-0': [Object] },
        params: {},
        arguments: {
          '747260a6-0f25-4a90-a546-8e91e91f3b86': [Object],
          '5f4c855c-d46e-4272-81ac-b43cdb10c37c': [Object]
        },
        message: {
          cadence: '\n' +
            '  transaction(name: String, code: String){\n' +
            '    prepare(acct: auth(AddContract, UpdateContract) &Account) {\n' +
            '      let decoded = code.decodeHex()\n' +
            '      \n' +
            '      if acct.contracts.get(name: name) == nil {\n' +
            '        acct.contracts.add(name: name, code: decoded)\n' +
            '      } else {\n' +
            '        acct.contracts.update(name: name, code: decoded)\n' +
            '      }\n' +
            '    }\n' +
            '  }\n',
          refBlock: 'a20c602fbee6fe4491e116403e3258e7b7924609696ab2edb9a93eed2c29e445',
          computeLimit: 9999,
          proposer: null,
          payer: null,
          authorizations: [],
          params: [],
          arguments: [Array]
        },
        proposer: '0xf8d6e0586b0a20c7-0',
        authorizations: [ '0xf8d6e0586b0a20c7-0' ],
        payer: [ '0xf8d6e0586b0a20c7-0' ],
        events: { eventType: null, start: null, end: null, blockIds: [] },
        subscribeEvents: {
          startBlockId: null,
          startHeight: null,
          eventTypes: null,
          addresses: null,
          contracts: null,
          heartbeatInterval: null
        },
        transaction: { id: null },
        block: { id: null, height: null, isSealed: null },
        account: { addr: null },
        collection: { id: null }
      }
    }

      at error (node_modules/@onflow/sdk/src/resolve/resolve-signatures.ts:48:15)
      at recPipe (node_modules/@onflow/sdk/src/interaction/interaction.ts:333:19)
      at Object.send (node_modules/@onflow/sdk/src/send/send.js:36:5)
@Luze26 Luze26 added the bug Something isn't working label May 23, 2024
@jribbink
Copy link
Contributor

@Luze26 Does this error still persist after upgrading your Flow CLI?

@Luze26
Copy link
Author

Luze26 commented May 23, 2024

@Luze26 Does this error still persist after upgrading your Flow CLI?

Seems like I still have the error.
When running flow-c1 version I get:
Version: v1.18.0-cadence-v1.0.0-preview.24 Commit: 6aac3b6c7f510feaf7728a48dd8ffa020feb6a0a

@jribbink
Copy link
Contributor

Hmmm ok, looking into this...

@jribbink
Copy link
Contributor

jribbink commented May 23, 2024

@Luze26 Does this error still persist after upgrading your Flow CLI?

Seems like I still have the error. When running flow-c1 version I get: Version: v1.18.0-cadence-v1.0.0-preview.24 Commit: 6aac3b6c7f510feaf7728a48dd8ffa020feb6a0a

I'm having trouble reproducing the issue. Can you post the node.js version that you are using? Wondering if this could be related.

Also is there any chance you could post a code snippet of the failing test?

@jribbink jribbink self-assigned this May 23, 2024
@Luze26
Copy link
Author

Luze26 commented May 24, 2024

@Luze26 Does this error still persist after upgrading your Flow CLI?

Seems like I still have the error. When running flow-c1 version I get: Version: v1.18.0-cadence-v1.0.0-preview.24 Commit: 6aac3b6c7f510feaf7728a48dd8ffa020feb6a0a

I'm having trouble reproducing the issue. Can you post the node.js version that you are using? Wondering if this could be related.

Also is there any chance you could post a code snippet of the failing test?

Thx for looking into it.
I tried with node 18 and 20 and got the same error.
I also tried to reproduce it with the basic test that is created running:

npx flow-js-testing init
npx flow-js-testing make basic-test

I then updated the dependencies to use the stable cadence version of flow-js-testing. And I get the same error, I also get this error with version 0.5.0.
You can find the code here: https://github.com/Luze26/flow-js-testing-bug-repro (it uses the version 0.5.0).
Previously we were using the old version of flow-js-testing that could be found here https://www.npmjs.com/package/flow-js-testing , but even when trying the last version of this lib, I get the same error.

I'll try to understand more the issue.

@Luze26
Copy link
Author

Luze26 commented May 24, 2024

So privateKey here

const key = ec[signAlgo].keyFromPrivate(Buffer.from(privateKey, "hex"))
is equal to the following object

{
	"type": "file",
	"location": "emulator-account.pkey"
}

So it fails, if I change the config in flow.json to directly include the key it works well.

@jribbink
Copy link
Contributor

Oh, nice catch :). Yeah this can be worked around in the library, I can make a PR.

@Luze26
Copy link
Author

Luze26 commented May 27, 2024

awesome, thx a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants