AoiSpringwind
AoiSpringwind

Reputation: 1

Sale cannot be executed in Kadena Pact Marmalde

Errors occur in the following conditions.

Running on local server (ubuntu on windows).

I deployed these files.

Token is minted.

The yaml file is generated via Django. The generated file is then used to run the API request formatter to generate Json.

Template:

code:
  (marmalade.ledger.sale
    (read-msg 'token-id)
    (read-msg 'account)
    (read-decimal 'amount)
    (read-integer 'timeout)
  )
data:
  token-id: "${token_id}"
  account: "${account}"
  amount: ${amount}
  timeout: ${timeout}
  quote:
    price: "${price}"
    recipient-guard:
      keys:
        [ "${recipient_key}", ]
    recipient: ${recipient}

keyPairs:
  - public: ${marmalade_pub}
    secret: ${marmalade_sec}
    caps:
      - name: "marmalade.ledger.SALE"
        args: ["${token_id}", "${account}", ${amount}, ${timeout}]

Generated File:

code:
  (marmalade.ledger.sale
    (read-msg 'token-id)
    (read-msg 'account)
    (read-decimal 'amount)
    (read-integer 'timeout)
  )
data:
  token-id: "92496e13-4414-4c58-aceb-0c7d77120af2"
  account: "a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76"
  amount: 1.0
  timeout: 100
  quote:
    price: "1.0"
    recipient-guard:
      keys:
        [ "52d9d996e6cc77f48a1ff1b734224a2ce6cee3af84c3f6e1720047645e9c2c31", ]
    recipient: a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76

keyPairs:
  - public: b63680e667576818b713d5d398ad395610b522fbc53e08afe46a719a0a128fb5
    secret: 4242d66fac539660702ce4f9c01a39bb16f1d6b6c7110c6647010cb4dd041dd8
    caps:
      - name: "marmalade.ledger.SALE"
        args: ["92496e13-4414-4c58-aceb-0c7d77120af2", "a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76", 1.0, 100]

JSON:

b'{"cmds":[{"hash":"cD5gqQVmRj08xqOdqfKwLLL2eb76_j_eZDdzV4Xdkjg","sigs":[{"sig":"2fb4bbb496271a138c33a4c8b94cf4511c8ad494b5c0cca94a2d1f98a37025e865b1414116fe77e841fbe71c6430e
5da72209123a63e958b992f4e8ba1770103"}],"cmd":"{\\"networkId\\":null,\\"payload\\":{\\"exec\\":{\\"data\\":{\\"amount\\":1.0,\\"token-id\\":\\"92496e13-4414-4c58-aceb-0c7d7712
0af2\\",\\"account\\":\\"a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76\\",\\"quote\\":{\\"recipient-guard\\":{\\"keys\\":[\\"52d9d996e6cc77f48a1ff1b734224a2ce6cee3
af84c3f6e1720047645e9c2c31\\"]},\\"price\\":\\"1.0\\",\\"recipient\\":\\"a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76\\"},\\"timeout\\":100},\\"code\\":\\"(marmal
ade.ledger.sale (read-msg \'token-id) (read-msg \'account) (read-decimal 
\'amount) (read-integer \'timeout) 
)\\"}},\\"signers\\":[{\\"pubKey\\":\\"b63680e667576818b713d5d398a
d395610b522fbc53e08afe46a719a0a128fb5\\",\\"clist\\":[{\\"args\\":[\\"92496e13-4414-4c58-aceb-0c7d77120af2\\",\\"a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76\\",1
,100],\\"name\\":\\"marmalade.ledger.SALE\\"}]}],\\"meta\\":{\\"creationTime\\":0,\\"ttl\\":0,\\"gasLimit\\":0,\\"chainId\\":\\"\\",\\"gasPrice\\":0,\\"sender\\":\\"\\"},\\"n
once\\":\\"2022-07-20 09:53:05.975872 UTC\\"}"}]}\n'

The following error occurred when I posted the Json data to request.post on 'localhost:8080/api/v1/poll'.

{'cD5gqQVmRj08xqOdqfKwLLL2eb76_j_eZDdzV4Xdkjg': {'gas': 0, 'result': {'status': 'failure', 'error': {'callStack': [], 'type': 'EvalError', 'message': 'Managed capability not installed: (marmalade.ledger.OFFER "92496e13-4414-4c58-aceb-0c7d77120af2" "a0fc037522ae0202052775f773e3cf823e3bd7640a12e80694b2dd76" 1.0 100)', 'info': ''}}, 'reqKey': 'cD5gqQVmRj08xqOdqfKwLLL2eb76_j_eZDdzV4Xdkjg', 'logs': None, 'metaData': None, 'continuation': None, 'txId': None}}

How do I get these to work properly?

P.S. I am Japanese and not an English speaker. I used a translation site to ask this question. Sorry if the description is missing.

Upvotes: 0

Views: 85

Answers (1)

Mubashir Farooq
Mubashir Farooq

Reputation: 81

problem in your request is that you don't installed marmalade.ledger.OFFER capability correctly, timeout in marmalade.ledger.OFFER must be an object with datatype and value. for example { int: 999999 }

1. first of all change your timeout input form 100 to { int: 100 }.

2. you may have to add coin.GAS capability too, otherwise it will give gas error (if your code work without it then it's fine)

3. also you may missing fungible description in data.quote that will give error also. if it give error about fungible description then add blew code in data.quote, after price

fungible: {
    refName: {
        name: "coin",
        namespace: null,
    },
    refSpec: [
        {
            name: "fungible-v2",
            namespace: null,
        },
    ],
},                      

Upvotes: 0

Related Questions