generated from wharfkit/api-client-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added get_abi_snapshot method
- Loading branch information
Showing
7 changed files
with
64 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
import {API, APIClient} from '@wharfkit/antelope' | ||
import {ABI, APIClient} from '@wharfkit/antelope' | ||
|
||
export class ExampleAPI { | ||
export class HyperionAPIClient { | ||
constructor(private client: APIClient) {} | ||
|
||
/** | ||
* Define the calls for the API | ||
*/ | ||
// async get_raw_abi(accountName: NameType) { | ||
// return this.call({ | ||
// path: '/v1/chain/get_raw_abi', | ||
// params: {account_name: Name.from(accountName)}, | ||
// responseType: GetRawAbiResponse, | ||
// }) | ||
// } | ||
async get_abi_snapshot(contract: string, block?: number, fetch = false): Promise<ABI.Def> { | ||
if (!block) { | ||
const info = await this.client.v1.chain.get_info() | ||
|
||
// Example for testing | ||
async get_info() { | ||
return this.client.call({ | ||
path: '/v1/chain/get_info', | ||
responseType: API.v1.GetInfoResponse, | ||
block = Number(info.last_irreversible_block_num) | ||
} | ||
|
||
return this.client.call<ABI.Def>({ | ||
path: `/v2/history/get_abi_snapshot?contract=${encodeURIComponent( | ||
contract | ||
)}&block=${block}&fetch=${fetch}`, | ||
method: 'GET', | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,3 @@ | ||
/** | ||
* Define the API response types | ||
* | ||
* Example and mock below | ||
*/ | ||
|
||
import {Struct} from '@wharfkit/antelope' | ||
|
||
@Struct.type('example_response') | ||
export class ExampleResponse extends Struct { | ||
@Struct.field('string') declare foo: string | ||
export interface Response { | ||
code: number | ||
} | ||
|
||
// import { | ||
// Blob, | ||
// Checksum256, | ||
// Name, | ||
// Struct, | ||
// } from '@wharfkit/antelope' | ||
|
||
// @Struct.type('get_raw_abi_response') | ||
// export class GetRawAbiResponse extends Struct { | ||
// @Struct.field('name') declare account_name: Name | ||
// @Struct.field('checksum256') declare code_hash: Checksum256 | ||
// @Struct.field('checksum256') declare abi_hash: Checksum256 | ||
// @Struct.field(Blob) declare abi: Blob | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"request": { | ||
"path": "https://eos.hyperion.eosrio.io/v2/history/get_abi_snapshot?contract=eosio.token&block=2000&fetch=true", | ||
"params": { | ||
"method": "GET" | ||
} | ||
}, | ||
"status": 200, | ||
"json": { | ||
"block_num": null, | ||
"present": false, | ||
"error": "abi not found for eosio.token until block 2000", | ||
"query_time_ms": 4, | ||
"last_indexed_block": 331963268, | ||
"last_indexed_block_time": "2023-09-20T00:35:04.500" | ||
}, | ||
"text": "{\"block_num\":null,\"present\":false,\"error\":\"abi not found for eosio.token until block 2000\",\"query_time_ms\":4,\"last_indexed_block\":331963268,\"last_indexed_block_time\":\"2023-09-20T00:35:04.500\"}" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters