Skip to content

Commit

Permalink
Implemented readonly method
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Jan 16, 2024
1 parent 90b7d9d commit f65a8c3
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
NameType,
PermissionLevel,
PermissionLevelType,
Serializer,
Transaction,
} from '@wharfkit/antelope'
import {PlaceholderAuth} from '@wharfkit/signing-request'

Expand Down Expand Up @@ -114,6 +116,33 @@ export class Contract {
)
}

public async readonly(name, data: ActionDataType): Promise<any> {
// Generate action
const action = this.action(name, data)
// Remove authorizations
action.authorization = []
// Assemble readonly transaction
const transaction = Transaction.from({
ref_block_num: 0,
ref_block_prefix: 0,
expiration: 0,
actions: [action],
})
// Execute and retrieve response
const response = await this.client.v1.chain.send_read_only_transaction(transaction)
// Decode and return results
const hexData = response.processed.action_traces[0].return_value_hex_data
const returnType = this.abi.action_results.find((a) => Name.from(a.name).equals(name))
if (!returnType) {
throw new Error(`Return type for ${name} not defined in the ABI.`)
}
return Serializer.decode({
data: hexData,
type: returnType.result_type,
abi: this.abi,
})
}

public actions(actions: ActionsArgs[], options?: ActionOptions): Action[] {
return actions.map((action) =>
this.action(action.name, action.data, {
Expand Down
69 changes: 69 additions & 0 deletions test/data/requests/05ffbae776e329473d0b26058142fbde12780727.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"request": {
"path": "https://jungle4.greymass.com/v1/chain/send_read_only_transaction",
"params": {
"method": "POST",
"body": "{\"transaction\":{\"signatures\":[],\"compression\":1,\"packed_context_free_data\":\"789c63000000010001\",\"packed_trx\":\"789c636040068c0c0d290dbed3379e02b20f840a2f7604d200440c05d1\"}}"
}
},
"status": 200,
"json": {
"transaction_id": "1fbb7d301410f8d071216f949d216555ad09bb06c719dbec6a7cdcbf366eb642",
"processed": {
"id": "1fbb7d301410f8d071216f949d216555ad09bb06c719dbec6a7cdcbf366eb642",
"block_num": 119346373,
"block_time": "2024-01-16T19:40:10.500",
"producer_block_id": null,
"receipt": {
"status": "executed",
"cpu_usage_us": 0,
"net_usage_words": 8
},
"elapsed": 34,
"net_usage": 64,
"scheduled": false,
"action_traces": [
{
"action_ordinal": 1,
"creator_action_ordinal": 0,
"closest_unnotified_ancestor_action_ordinal": 0,
"receipt": {
"receiver": "testing.gm",
"act_digest": "0bcba5b6899391bd989fe4d3054dd802da3227a6e4377fc2d529ad6df348932d",
"global_sequence": 0,
"recv_sequence": 0,
"auth_sequence": [],
"code_sequence": 265,
"abi_sequence": 96
},
"receiver": "testing.gm",
"act": {
"account": "testing.gm",
"name": "callapi",
"authorization": [],
"data": "",
"hex_data": ""
},
"context_free": false,
"elapsed": 21,
"console": "",
"trx_id": "1fbb7d301410f8d071216f949d216555ad09bb06c719dbec6a7cdcbf366eb642",
"block_num": 119346373,
"block_time": "2024-01-16T19:40:10.500",
"producer_block_id": null,
"account_ram_deltas": [],
"except": null,
"error_code": null,
"return_value_hex_data": "0100000000000000",
"return_value_data": {
"foo": 1
}
}
],
"account_ram_delta": null,
"except": null,
"error_code": null
}
},
"text": "{\"transaction_id\":\"1fbb7d301410f8d071216f949d216555ad09bb06c719dbec6a7cdcbf366eb642\",\"processed\":{\"id\":\"1fbb7d301410f8d071216f949d216555ad09bb06c719dbec6a7cdcbf366eb642\",\"block_num\":119346373,\"block_time\":\"2024-01-16T19:40:10.500\",\"producer_block_id\":null,\"receipt\":{\"status\":\"executed\",\"cpu_usage_us\":0,\"net_usage_words\":8},\"elapsed\":34,\"net_usage\":64,\"scheduled\":false,\"action_traces\":[{\"action_ordinal\":1,\"creator_action_ordinal\":0,\"closest_unnotified_ancestor_action_ordinal\":0,\"receipt\":{\"receiver\":\"testing.gm\",\"act_digest\":\"0bcba5b6899391bd989fe4d3054dd802da3227a6e4377fc2d529ad6df348932d\",\"global_sequence\":0,\"recv_sequence\":0,\"auth_sequence\":[],\"code_sequence\":265,\"abi_sequence\":96},\"receiver\":\"testing.gm\",\"act\":{\"account\":\"testing.gm\",\"name\":\"callapi\",\"authorization\":[],\"data\":\"\",\"hex_data\":\"\"},\"context_free\":false,\"elapsed\":21,\"console\":\"\",\"trx_id\":\"1fbb7d301410f8d071216f949d216555ad09bb06c719dbec6a7cdcbf366eb642\",\"block_num\":119346373,\"block_time\":\"2024-01-16T19:40:10.500\",\"producer_block_id\":null,\"account_ram_deltas\":[],\"except\":null,\"error_code\":null,\"return_value_hex_data\":\"0100000000000000\",\"return_value_data\":{\"foo\":1}}],\"account_ram_delta\":null,\"except\":null,\"error_code\":null}}"
}
69 changes: 69 additions & 0 deletions test/data/requests/4b93af13d7e51718dd619f34325aa02da32cce8d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"request": {
"path": "https://jungle4.greymass.com/v1/chain/send_read_only_transaction",
"params": {
"method": "POST",
"body": "{\"transaction\":{\"signatures\":[],\"compression\":1,\"packed_context_free_data\":\"789c63000000010001\",\"packed_trx\":\"789c636040068c06c71c8e2f48be60c830a52fedfceacdbb1838c0e2528bb31800a31509a1\"}}"
}
},
"status": 200,
"json": {
"transaction_id": "f0ec94d0dfdfd810cbdfb88d6ee43e6314e0fea623886ecccfb35284f1ee48be",
"processed": {
"id": "f0ec94d0dfdfd810cbdfb88d6ee43e6314e0fea623886ecccfb35284f1ee48be",
"block_num": 119346372,
"block_time": "2024-01-16T19:40:10.000",
"producer_block_id": null,
"receipt": {
"status": "executed",
"cpu_usage_us": 0,
"net_usage_words": 9
},
"elapsed": 66,
"net_usage": 72,
"scheduled": false,
"action_traces": [
{
"action_ordinal": 1,
"creator_action_ordinal": 0,
"closest_unnotified_ancestor_action_ordinal": 0,
"receipt": {
"receiver": "abcabcabc333",
"act_digest": "c065e5fbaadf68523d6da2ea62aa49cf876468ec441aea6c6ece2263b35ed8a9",
"global_sequence": 0,
"recv_sequence": 0,
"auth_sequence": [],
"code_sequence": 5,
"abi_sequence": 5
},
"receiver": "abcabcabc333",
"act": {
"account": "abcabcabc333",
"name": "returnvalue",
"authorization": [],
"data": {
"message": "hello"
},
"hex_data": "00000000001aa36a"
},
"context_free": false,
"elapsed": 43,
"console": "",
"trx_id": "f0ec94d0dfdfd810cbdfb88d6ee43e6314e0fea623886ecccfb35284f1ee48be",
"block_num": 119346372,
"block_time": "2024-01-16T19:40:10.000",
"producer_block_id": null,
"account_ram_deltas": [],
"except": null,
"error_code": null,
"return_value_hex_data": "1656616c69646174696f6e20686173207061737365642e",
"return_value_data": "Validation has passed."
}
],
"account_ram_delta": null,
"except": null,
"error_code": null
}
},
"text": "{\"transaction_id\":\"f0ec94d0dfdfd810cbdfb88d6ee43e6314e0fea623886ecccfb35284f1ee48be\",\"processed\":{\"id\":\"f0ec94d0dfdfd810cbdfb88d6ee43e6314e0fea623886ecccfb35284f1ee48be\",\"block_num\":119346372,\"block_time\":\"2024-01-16T19:40:10.000\",\"producer_block_id\":null,\"receipt\":{\"status\":\"executed\",\"cpu_usage_us\":0,\"net_usage_words\":9},\"elapsed\":66,\"net_usage\":72,\"scheduled\":false,\"action_traces\":[{\"action_ordinal\":1,\"creator_action_ordinal\":0,\"closest_unnotified_ancestor_action_ordinal\":0,\"receipt\":{\"receiver\":\"abcabcabc333\",\"act_digest\":\"c065e5fbaadf68523d6da2ea62aa49cf876468ec441aea6c6ece2263b35ed8a9\",\"global_sequence\":0,\"recv_sequence\":0,\"auth_sequence\":[],\"code_sequence\":5,\"abi_sequence\":5},\"receiver\":\"abcabcabc333\",\"act\":{\"account\":\"abcabcabc333\",\"name\":\"returnvalue\",\"authorization\":[],\"data\":{\"message\":\"hello\"},\"hex_data\":\"00000000001aa36a\"},\"context_free\":false,\"elapsed\":43,\"console\":\"\",\"trx_id\":\"f0ec94d0dfdfd810cbdfb88d6ee43e6314e0fea623886ecccfb35284f1ee48be\",\"block_num\":119346372,\"block_time\":\"2024-01-16T19:40:10.000\",\"producer_block_id\":null,\"account_ram_deltas\":[],\"except\":null,\"error_code\":null,\"return_value_hex_data\":\"1656616c69646174696f6e20686173207061737365642e\",\"return_value_data\":\"Validation has passed.\"}],\"account_ram_delta\":null,\"except\":null,\"error_code\":null}}"
}
17 changes: 17 additions & 0 deletions test/data/requests/5dca85e4f7a17451d3909daa1ff340e6bbde29e6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"request": {
"path": "https://jungle4.greymass.com/v1/chain/get_raw_abi",
"params": {
"method": "POST",
"body": "{\"account_name\":\"abcabcabc333\"}"
}
},
"status": 200,
"json": {
"account_name": "abcabcabc333",
"code_hash": "bd288915b11aceba37d0aed6441dc55418e2ea372e4edefa76f5d137dbd98c3f",
"abi_hash": "908e079610cee2bdd38870195f5de416eb0ed0f7511eb2e4b8ada78372613ad6",
"abi": "DmVvc2lvOjphYmkvMS4yAAUGY3VzdG9tAAIHbWVzc2FnZQZzdHJpbmcFZXh0cmEGc3RyaW5nC2N1c3RvbXZhbHVlAAEHbWVzc2FnZQZzdHJpbmcJbmFtZXZhbHVlAAEHbWVzc2FnZQRuYW1lC251bWJlcnZhbHVlAAEHbWVzc2FnZQRuYW1lC3JldHVybnZhbHVlAAEHbWVzc2FnZQRuYW1lBACUjmZLmrFGC2N1c3RvbXZhbHVlAAAAUDqaraSZCW5hbWV2YWx1ZQAAlI5mX3WkngtudW1iZXJ2YWx1ZQAAlI5mz6uzugtyZXR1cm52YWx1ZQAAAAAAAAQAlI5mS5qxRgZjdXN0b20AAFA6mq2kmQRuYW1lAJSOZl91pJ4GdWludDY0AJSOZs+rs7oGc3RyaW5nAA=="
},
"text": "{\"account_name\":\"abcabcabc333\",\"code_hash\":\"bd288915b11aceba37d0aed6441dc55418e2ea372e4edefa76f5d137dbd98c3f\",\"abi_hash\":\"908e079610cee2bdd38870195f5de416eb0ed0f7511eb2e4b8ada78372613ad6\",\"abi\":\"DmVvc2lvOjphYmkvMS4yAAUGY3VzdG9tAAIHbWVzc2FnZQZzdHJpbmcFZXh0cmEGc3RyaW5nC2N1c3RvbXZhbHVlAAEHbWVzc2FnZQZzdHJpbmcJbmFtZXZhbHVlAAEHbWVzc2FnZQRuYW1lC251bWJlcnZhbHVlAAEHbWVzc2FnZQRuYW1lC3JldHVybnZhbHVlAAEHbWVzc2FnZQRuYW1lBACUjmZLmrFGC2N1c3RvbXZhbHVlAAAAUDqaraSZCW5hbWV2YWx1ZQAAlI5mX3WkngtudW1iZXJ2YWx1ZQAAlI5mz6uzugtyZXR1cm52YWx1ZQAAAAAAAAQAlI5mS5qxRgZjdXN0b20AAFA6mq2kmQRuYW1lAJSOZl91pJ4GdWludDY0AJSOZs+rs7oGc3RyaW5nAA==\"}"
}
17 changes: 17 additions & 0 deletions test/data/requests/f273eb23c3db6f7d2e0388995f3d88f9b2df650a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"request": {
"path": "https://jungle4.greymass.com/v1/chain/get_raw_abi",
"params": {
"method": "POST",
"body": "{\"account_name\":\"testing.gm\"}"
}
},
"status": 200,
"json": {
"account_name": "testing.gm",
"code_hash": "fb408223bf6041be74521d58dd57489b25012bf0abb91f3eee4ac71ead101e0b",
"abi_hash": "c5d8f4b102b5dccba41f413741fa51833f501c14ae5992860dca1803f02fca07",
"abi": "DmVvc2lvOjphYmkvMS4yABsMYXBpX3Jlc3BvbnNlAAEDZm9vBnVpbnQ2NAdjYWxsYXBpAAALYWNjb3VudF9yb3cAAgdhY2NvdW50BG5hbWUFc2VlZHMGdWludDMyCWFkZG9yYWNsZQABBm9yYWNsZQRuYW1lB2FkdmFuY2UAAAZjb21taXQAAwZvcmFjbGUEbmFtZQVlcG9jaAZ1aW50NjQGY29tbWl0C2NoZWNrc3VtMjU2CmNvbW1pdF9yb3cABAJpZAZ1aW50NjQFZXBvY2gGdWludDY0Bm9yYWNsZQRuYW1lBmNvbW1pdAtjaGVja3N1bTI1Ngdjb21wdXRlAAIFZXBvY2gGdWludDY0BHNlZWQGdWludDY0B2Rlc3Ryb3kAAgVvd25lcgRuYW1lCnRvX2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2YW5jZQAAAAAAZCclRQZjb21taXQAAAAAQGVdJUUHY29tcHV0ZQAAAADA05uxSgdkZXN0cm95AABAjMbTm7FKCmRlc3Ryb3lhbGwAAAAAAKh4zFQGZW5hYmxlAAAAAADESO9UBmVucm9sbAAwb74qm6umYgxnZW5lcmF0ZXJ0cm4AAAAAAACQ3XQEaW5pdACgIjKXqk2lugxyZW1vdmVvcmFjbGUAAAAAAESjtroGcmV2ZWFsAAAAAFctPM3NCHRyYW5zZmVyAAAAAAAAoKrjBHdpcGUAAAAASlKsquMId2lwZXNvbWUACAAAADhPTREyA2k2NAAAC2FjY291bnRfcm93AAAAAGcnJUUDaTY0AAAKY29tbWl0X3JvdwAAAADghmhVA2k2NAAACWVwb2NoX3JvdwAAAACriMylA2k2NAAACm9yYWNsZV9yb3cAAAAAR6O2ugNpNjQAAApyZXZlYWxfcm93AAAAAACclMIDaTY0AAAIc2VlZF9yb3cAAAAAAJVNxgNpNjQAAAlzdGF0ZV9yb3cAAAAAAJxNxgNpNjQAAAhzdGF0X3JvdwAAAAAFAAAAwFUTo0EMYXBpX3Jlc3BvbnNlAAAAQKFpdjIJZXBvY2hfcm93AAAAQGVdJUULY2hlY2tzdW0yNTYAAADA05uxShRkZXN0cm95X3JldHVybl92YWx1ZTBvviqbq6ZiFWdlbmVyYXRlX3JldHVybl92YWx1ZQ=="
},
"text": "{\"account_name\":\"testing.gm\",\"code_hash\":\"fb408223bf6041be74521d58dd57489b25012bf0abb91f3eee4ac71ead101e0b\",\"abi_hash\":\"c5d8f4b102b5dccba41f413741fa51833f501c14ae5992860dca1803f02fca07\",\"abi\":\"DmVvc2lvOjphYmkvMS4yABsMYXBpX3Jlc3BvbnNlAAEDZm9vBnVpbnQ2NAdjYWxsYXBpAAALYWNjb3VudF9yb3cAAgdhY2NvdW50BG5hbWUFc2VlZHMGdWludDMyCWFkZG9yYWNsZQABBm9yYWNsZQRuYW1lB2FkdmFuY2UAAAZjb21taXQAAwZvcmFjbGUEbmFtZQVl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XRlX3JvdwADAmlkBnVpbnQxNgVlcG9jaAZ1aW50NjQHZW5hYmxlZARib29sCHRyYW5zZmVyAAMEZnJvbQRuYW1lAnRvBG5hbWULdG9fdHJhbnNmZXIIdWludDY0W10Ed2lwZQAACHdpcGVzb21lAAAQAAAAwFUTo0EHY2FsbGFwaQAAAFARmUtTMglhZGRvcmFjbGUAAAAAQKFpdjIHYWR2YW5jZQAAAAAAZCclRQZjb21taXQAAAAAQGVdJUUHY29tcHV0ZQAAAADA05uxSgdkZXN0cm95AABAjMbTm7FKCmRlc3Ryb3lhbGwAAAAAAKh4zFQGZW5hYmxlAAAAAADESO9UBmVucm9sbAAwb74qm6umYgxnZW5lcmF0ZXJ0cm4AAAAAAACQ3XQEaW5pdACgIjKXqk2lugxyZW1vdmVvcmFjbGUAAAAAAESjtroGcmV2ZWFsAAAAAFctPM3NCHRyYW5zZmVyAAAAAAAAoKrjBHdpcGUAAAAASlKsquMId2lwZXNvbWUACAAAADhPTREyA2k2NAAAC2FjY291bnRfcm93AAAAAGcnJUUDaTY0AAAKY29tbWl0X3JvdwAAAADghmhVA2k2NAAACWVwb2NoX3JvdwAAAACriMylA2k2NAAACm9yYWNsZV9yb3cAAAAAR6O2ugNpNjQAAApyZXZlYWxfcm93AAAAAACclMIDaTY0AAAIc2VlZF9yb3cAAAAAAJVNxgNpNjQAAAlzdGF0ZV9yb3cAAAAAAJxNxgNpNjQAAAhzdGF0X3JvdwAAAAAFAAAAwFUTo0EMYXBpX3Jlc3BvbnNlAAAAQKFpdjIJZXBvY2hfcm93AAAAQGVdJUULY2hlY2tzdW0yNTYAAADA05uxShRkZXN0cm95X3JldHVybl92YWx1ZTBvviqbq6ZiFWdlbmVyYXRlX3JldHVybl92YWx1ZQ==\"}"
}
17 changes: 16 additions & 1 deletion test/tests/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {assert} from 'chai'

import ContractKit, {Contract, ContractArgs, Table} from '$lib'
import {DelegatedBandwidth, ProducerInfo} from '$test/data/structs/eosio'
import {ABI, Action, Asset, Name, PrivateKey, Serializer} from '@wharfkit/antelope'
import {ABI, Action, Asset, Name, PrivateKey, Serializer, UInt64} from '@wharfkit/antelope'
import {PlaceholderAuth} from '@wharfkit/signing-request'
import {runGenericContractTests} from './helpers/generic'

Expand Down Expand Up @@ -361,5 +361,20 @@ suite('Contract', async function () {
assert.instanceOf(error, Error)
})
})

suite('readonly transaction', () => {
test('basic return', async () => {
const contract = await mockKit.load('abcabcabc333')
const result = await contract.readonly('returnvalue', {
message: 'hello',
})
assert.equal(result, 'Validation has passed.')
})
test('dynamic encoded return', async () => {
const contract = await mockKit.load('testing.gm')
const result = await contract.readonly('callapi', {})
assert.instanceOf(result.foo, UInt64)
})
})
})
})

0 comments on commit f65a8c3

Please sign in to comment.