formancehq / stack

Open Source Infrastructure for the Financial Internet
https://www.formance.com
Other
359 stars 50 forks source link

v2AddMetadataToAccount doesn't accept an address with a colon, e.g. "user:1234" #1615

Open arnarhf opened 3 months ago

arnarhf commented 3 months ago

Using v2CreateTransaction you can create a transaction for an address which includes a colon ("user:1234"), e.g.

send EUR/2 500 (
  source = world
  destination = user:1234
)

But you then cannot call v2AddMetadataToAccount for the same address:

await ledger.v2AddMetadataToAccount({
  ledger: ledgerName, 
  address: 'user:1234',
  requestBody: {
    id: 'my-meta-data-value'
  }
})

Using addresses with an underscore works fine ("user_1234"), but it's surprising that a colon doesn't given that it's used in many of your examples.

Using Node, Typescript and "@formance/formance-sdk": "^2.4.4".

Shiroy commented 3 months ago

Hey @arnarhf ,

What error do you see exactly?

arnarhf commented 3 months ago

Hi @Shiroy ,

Apologies, I should have included that.

This is what I get when using an address like "deposit:1234" but not when using an address like "deposit_1234". Note, I'm playing with the kittie tutorial, adapting it to Formance Ledger v2.

c:\dev\Formance\kittie-app-tutorial\node_modules\@formance\formance-sdk\src\sdk\models\errors\v2errorresponse.ts:56
            return new V2ErrorResponse(v);
                   ^
V2ErrorResponse: API error occurred
    at Object.transform (c:\dev\Formance\kittie-app-tutorial\node_modules\@formance\formance-sdk\src\sdk\models\errors\v2errorresponse.ts:56:20)
    at ZodEffects._parse (c:\dev\Formance\kittie-app-tutorial\node_modules\zod\lib\types.js:3224:39)
    at ZodEffects._parseSync (c:\dev\Formance\kittie-app-tutorial\node_modules\zod\lib\types.js:146:29)
    at ZodEffects.safeParse (c:\dev\Formance\kittie-app-tutorial\node_modules\zod\lib\types.js:176:29)
    at ZodEffects.parse (c:\dev\Formance\kittie-app-tutorial\node_modules\zod\lib\types.js:157:29)
    at c:\dev\Formance\kittie-app-tutorial\node_modules\@formance\formance-sdk\src\lib\http.ts:474:57
    at parse (c:\dev\Formance\kittie-app-tutorial\node_modules\@formance\formance-sdk\src\lib\schemas.ts:15:16)
    at ResponseMatcher.match (c:\dev\Formance\kittie-app-tutorial\node_modules\@formance\formance-sdk\src\lib\http.ts:474:27)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Ledger.v2AddMetadataToAccount (c:\dev\Formance\kittie-app-tutorial\node_modules\@formance\formance-sdk\src\sdk\ledger.ts:1821:27) {
  'data$': {
    errorCode: 'VALIDATION',
    errorMessage: 'invalid account address format'
  },
  errorCode: 'VALIDATION',
  errorMessage: 'invalid account address format'
}
flemzord commented 3 months ago

Hello @arnarhf

We've just released a new version of the SDK that fixes this.

Regards