diff --git a/src/api/v1/chain.ts b/src/api/v1/chain.ts index 524d1a8..abc1dff 100644 --- a/src/api/v1/chain.ts +++ b/src/api/v1/chain.ts @@ -27,6 +27,8 @@ import { GetBlockResponse, GetInfoResponse, GetProducerScheduleResponse, + GetProtocolFeaturesParams, + GetProtocolFeaturesResponse, GetTableByScopeParams, GetTableByScopeResponse, GetTableRowsParams, @@ -71,6 +73,14 @@ export class ChainAPI { }) } + async get_activated_protocol_features(params?: GetProtocolFeaturesParams) { + return this.client.call({ + path: '/v1/chain/get_activated_protocol_features', + params, + responseType: GetProtocolFeaturesResponse, + }) + } + async get_block(block_num_or_id: Checksum256Type | UInt32Type) { return this.client.call({ path: '/v1/chain/get_block', diff --git a/src/api/v1/types.ts b/src/api/v1/types.ts index e1f2227..a688207 100644 --- a/src/api/v1/types.ts +++ b/src/api/v1/types.ts @@ -642,3 +642,34 @@ export class GetProducerScheduleResponse extends Struct { @Struct.field(ProducerSchedule, {optional: true}) declare pending: ProducerSchedule @Struct.field(ProducerSchedule, {optional: true}) declare proposed: ProducerSchedule } + +@Struct.type('protocol_feature') +export class ProtocolFeature extends Struct { + @Struct.field('checksum256') declare feature_digest: Checksum256 + @Struct.field('uint32') declare activation_ordinal: UInt32 + @Struct.field('uint32') declare activation_block_num: UInt32 + @Struct.field('checksum256') declare description_digest: Checksum256 + @Struct.field('string', {array: true}) declare dependencies: string[] + @Struct.field('string') declare protocol_feature_type: string + @Struct.field('any', {array: true}) declare specification: any[] +} + +@Struct.type('get_protocol_features_response') +export class GetProtocolFeaturesResponse extends Struct { + @Struct.field(ProtocolFeature, {array: true}) + declare activated_protocol_features: ProtocolFeature[] + @Struct.field('uint32', {optional: true}) declare more: UInt32 +} + +export interface GetProtocolFeaturesParams { + /** Lower lookup bound. */ + lower_bound?: UInt32 | number + /** Upper lookup bound. */ + upper_bound?: UInt32 | number + /** How many rows to fetch, defaults to 10 if unset. */ + limit?: UInt32Type + /** Flag to indicate it is has to search by block number */ + search_by_block_num?: boolean + /** Whether to iterate records in reverse order. */ + reverse?: boolean +} diff --git a/test/api.ts b/test/api.ts index 9436f19..842eb92 100644 --- a/test/api.ts +++ b/test/api.ts @@ -105,6 +105,29 @@ suite('api v1', function () { assert.isTrue(response.accounts[0].threshold.equals(1)) }) + test('chain get_activated_protocol_features', async function () { + const response = await jungle4.v1.chain.get_activated_protocol_features() + assert.lengthOf(response.activated_protocol_features, 10) + assert.isTrue(response.more.equals(10)) + const [feature] = response.activated_protocol_features + assert.isTrue( + feature.feature_digest.equals( + '0ec7e080177b2c02b278d5088611686b49d739925a92d9bfcacd7fc6b74053bd' + ) + ) + assert.isTrue(feature.activation_ordinal.equals(0)) + assert.isTrue(feature.activation_block_num.equals(4)) + assert.isTrue( + feature.description_digest.equals( + '64fe7df32e9b86be2b296b3f81dfd527f84e82b98e363bc97e40bc7a83733310' + ) + ) + assert.isArray(feature.dependencies) + assert.lengthOf(feature.dependencies, 0) + assert.equal(feature.protocol_feature_type, 'builtin') + assert.isArray(feature.specification) + }) + test('chain get_block (by id)', async function () { const block = await eos.v1.chain.get_block( '00816d41e41f1462acb648b810b20f152d944fabd79aaff31c9f50102e4e5db9' diff --git a/test/data/15cd04ae0e6232dabb0c9946f99ccb2b2be6393f.json b/test/data/15cd04ae0e6232dabb0c9946f99ccb2b2be6393f.json new file mode 100644 index 0000000..7c8e74b --- /dev/null +++ b/test/data/15cd04ae0e6232dabb0c9946f99ccb2b2be6393f.json @@ -0,0 +1,161 @@ +{ + "headers": { + "access-control-allow-headers": "Origin, X-Requested-With, Content-Type, Accept", + "access-control-allow-methods": "GET, POST, HEAD, OPTIONS", + "access-control-allow-origin": "*", + "connection": "close", + "content-length": "3729", + "content-type": "application/json", + "date": "Sun, 16 Apr 2023 21:09:20 GMT", + "server": "nginx/1.24.0" + }, + "status": 200, + "json": { + "activated_protocol_features": [ + { + "feature_digest": "0ec7e080177b2c02b278d5088611686b49d739925a92d9bfcacd7fc6b74053bd", + "activation_ordinal": 0, + "activation_block_num": 4, + "description_digest": "64fe7df32e9b86be2b296b3f81dfd527f84e82b98e363bc97e40bc7a83733310", + "dependencies": [], + "protocol_feature_type": "builtin", + "specification": [ + { + "name": "builtin_feature_codename", + "value": "PREACTIVATE_FEATURE" + } + ] + }, + { + "feature_digest": "f0af56d2c5a48d60a4a5b5c903edfb7db3a736a94ed589d0b797df33ff9d3e1d", + "activation_ordinal": 1, + "activation_block_num": 12, + "description_digest": "1eab748b95a2e6f4d7cb42065bdee5566af8efddf01a55a0a8d831b823f8828a", + "dependencies": [], + "protocol_feature_type": "builtin", + "specification": [ + { + "name": "builtin_feature_codename", + "value": "GET_SENDER" + } + ] + }, + { + "feature_digest": "2652f5f96006294109b3dd0bbde63693f55324af452b799ee137a81a905eed25", + "activation_ordinal": 2, + "activation_block_num": 12, + "description_digest": "898082c59f921d0042e581f00a59d5ceb8be6f1d9c7a45b6f07c0e26eaee0222", + "dependencies": [], + "protocol_feature_type": "builtin", + "specification": [ + { + "name": "builtin_feature_codename", + "value": "FORWARD_SETCODE" + } + ] + }, + { + "feature_digest": "8ba52fe7a3956c5cd3a656a3174b931d3bb2abb45578befc59f283ecd816a405", + "activation_ordinal": 3, + "activation_block_num": 12, + "description_digest": "2f1f13e291c79da5a2bbad259ed7c1f2d34f697ea460b14b565ac33b063b73e2", + "dependencies": [], + "protocol_feature_type": "builtin", + "specification": [ + { + "name": "builtin_feature_codename", + "value": "ONLY_BILL_FIRST_AUTHORIZER" + } + ] + }, + { + "feature_digest": "ad9e3d8f650687709fd68f4b90b41f7d825a365b02c23a636cef88ac2ac00c43", + "activation_ordinal": 4, + "activation_block_num": 12, + "description_digest": "e71b6712188391994c78d8c722c1d42c477cf091e5601b5cf1befd05721a57f3", + "dependencies": [], + "protocol_feature_type": "builtin", + "specification": [ + { + "name": "builtin_feature_codename", + "value": "RESTRICT_ACTION_TO_SELF" + } + ] + }, + { + "feature_digest": "68dcaa34c0517d19666e6b33add67351d8c5f69e999ca1e37931bc410a297428", + "activation_ordinal": 5, + "activation_block_num": 12, + "description_digest": "2853617cec3eabd41881eb48882e6fc5e81a0db917d375057864b3befbe29acd", + "dependencies": [], + "protocol_feature_type": "builtin", + "specification": [ + { + "name": "builtin_feature_codename", + "value": "DISALLOW_EMPTY_PRODUCER_SCHEDULE" + } + ] + }, + { + "feature_digest": "e0fb64b1085cc5538970158d05a009c24e276fb94e1a0bf6a528b48fbc4ff526", + "activation_ordinal": 6, + "activation_block_num": 12, + "description_digest": "a98241c83511dc86c857221b9372b4aa7cea3aaebc567a48604e1d3db3557050", + "dependencies": [], + "protocol_feature_type": "builtin", + "specification": [ + { + "name": "builtin_feature_codename", + "value": "FIX_LINKAUTH_RESTRICTION" + } + ] + }, + { + "feature_digest": "ef43112c6543b88db2283a2e077278c315ae2c84719a8b25f25cc88565fbea99", + "activation_ordinal": 7, + "activation_block_num": 12, + "description_digest": "9908b3f8413c8474ab2a6be149d3f4f6d0421d37886033f27d4759c47a26d944", + "dependencies": [], + "protocol_feature_type": "builtin", + "specification": [ + { + "name": "builtin_feature_codename", + "value": "REPLACE_DEFERRED" + } + ] + }, + { + "feature_digest": "4a90c00d55454dc5b059055ca213579c6ea856967712a56017487886a4d4cc0f", + "activation_ordinal": 8, + "activation_block_num": 12, + "description_digest": "45967387ee92da70171efd9fefd1ca8061b5efe6f124d269cd2468b47f1575a0", + "dependencies": [ + "ef43112c6543b88db2283a2e077278c315ae2c84719a8b25f25cc88565fbea99" + ], + "protocol_feature_type": "builtin", + "specification": [ + { + "name": "builtin_feature_codename", + "value": "NO_DUPLICATE_DEFERRED_ID" + } + ] + }, + { + "feature_digest": "1a99a59d87e06e09ec5b028a9cbb7749b4a5ad8819004365d02dc4379a8b7241", + "activation_ordinal": 9, + "activation_block_num": 12, + "description_digest": "f3c3d91c4603cde2397268bfed4e662465293aab10cd9416db0d442b8cec2949", + "dependencies": [], + "protocol_feature_type": "builtin", + "specification": [ + { + "name": "builtin_feature_codename", + "value": "ONLY_LINK_TO_EXISTING_PERMISSION" + } + ] + } + ], + "more": 10 + }, + "text": "{\"activated_protocol_features\":[{\"feature_digest\":\"0ec7e080177b2c02b278d5088611686b49d739925a92d9bfcacd7fc6b74053bd\",\"activation_ordinal\":0,\"activation_block_num\":4,\"description_digest\":\"64fe7df32e9b86be2b296b3f81dfd527f84e82b98e363bc97e40bc7a83733310\",\"dependencies\":[],\"protocol_feature_type\":\"builtin\",\"specification\":[{\"name\":\"builtin_feature_codename\",\"value\":\"PREACTIVATE_FEATURE\"}]},{\"feature_digest\":\"f0af56d2c5a48d60a4a5b5c903edfb7db3a736a94ed589d0b797df33ff9d3e1d\",\"activation_ordinal\":1,\"activation_block_num\":12,\"description_digest\":\"1eab748b95a2e6f4d7cb42065bdee5566af8efddf01a55a0a8d831b823f8828a\",\"dependencies\":[],\"protocol_feature_type\":\"builtin\",\"specification\":[{\"name\":\"builtin_feature_codename\",\"value\":\"GET_SENDER\"}]},{\"feature_digest\":\"2652f5f96006294109b3dd0bbde63693f55324af452b799ee137a81a905eed25\",\"activation_ordinal\":2,\"activation_block_num\":12,\"description_digest\":\"898082c59f921d0042e581f00a59d5ceb8be6f1d9c7a45b6f07c0e26eaee0222\",\"dependencies\":[],\"protocol_feature_type\":\"builtin\",\"specification\":[{\"name\":\"builtin_feature_codename\",\"value\":\"FORWARD_SETCODE\"}]},{\"feature_digest\":\"8ba52fe7a3956c5cd3a656a3174b931d3bb2abb45578befc59f283ecd816a405\",\"activation_ordinal\":3,\"activation_block_num\":12,\"description_digest\":\"2f1f13e291c79da5a2bbad259ed7c1f2d34f697ea460b14b565ac33b063b73e2\",\"dependencies\":[],\"protocol_feature_type\":\"builtin\",\"specification\":[{\"name\":\"builtin_feature_codename\",\"value\":\"ONLY_BILL_FIRST_AUTHORIZER\"}]},{\"feature_digest\":\"ad9e3d8f650687709fd68f4b90b41f7d825a365b02c23a636cef88ac2ac00c43\",\"activation_ordinal\":4,\"activation_block_num\":12,\"description_digest\":\"e71b6712188391994c78d8c722c1d42c477cf091e5601b5cf1befd05721a57f3\",\"dependencies\":[],\"protocol_feature_type\":\"builtin\",\"specification\":[{\"name\":\"builtin_feature_codename\",\"value\":\"RESTRICT_ACTION_TO_SELF\"}]},{\"feature_digest\":\"68dcaa34c0517d19666e6b33add67351d8c5f69e999ca1e37931bc410a297428\",\"activation_ordinal\":5,\"activation_block_num\":12,\"description_digest\":\"2853617cec3eabd41881eb48882e6fc5e81a0db917d375057864b3befbe29acd\",\"dependencies\":[],\"protocol_feature_type\":\"builtin\",\"specification\":[{\"name\":\"builtin_feature_codename\",\"value\":\"DISALLOW_EMPTY_PRODUCER_SCHEDULE\"}]},{\"feature_digest\":\"e0fb64b1085cc5538970158d05a009c24e276fb94e1a0bf6a528b48fbc4ff526\",\"activation_ordinal\":6,\"activation_block_num\":12,\"description_digest\":\"a98241c83511dc86c857221b9372b4aa7cea3aaebc567a48604e1d3db3557050\",\"dependencies\":[],\"protocol_feature_type\":\"builtin\",\"specification\":[{\"name\":\"builtin_feature_codename\",\"value\":\"FIX_LINKAUTH_RESTRICTION\"}]},{\"feature_digest\":\"ef43112c6543b88db2283a2e077278c315ae2c84719a8b25f25cc88565fbea99\",\"activation_ordinal\":7,\"activation_block_num\":12,\"description_digest\":\"9908b3f8413c8474ab2a6be149d3f4f6d0421d37886033f27d4759c47a26d944\",\"dependencies\":[],\"protocol_feature_type\":\"builtin\",\"specification\":[{\"name\":\"builtin_feature_codename\",\"value\":\"REPLACE_DEFERRED\"}]},{\"feature_digest\":\"4a90c00d55454dc5b059055ca213579c6ea856967712a56017487886a4d4cc0f\",\"activation_ordinal\":8,\"activation_block_num\":12,\"description_digest\":\"45967387ee92da70171efd9fefd1ca8061b5efe6f124d269cd2468b47f1575a0\",\"dependencies\":[\"ef43112c6543b88db2283a2e077278c315ae2c84719a8b25f25cc88565fbea99\"],\"protocol_feature_type\":\"builtin\",\"specification\":[{\"name\":\"builtin_feature_codename\",\"value\":\"NO_DUPLICATE_DEFERRED_ID\"}]},{\"feature_digest\":\"1a99a59d87e06e09ec5b028a9cbb7749b4a5ad8819004365d02dc4379a8b7241\",\"activation_ordinal\":9,\"activation_block_num\":12,\"description_digest\":\"f3c3d91c4603cde2397268bfed4e662465293aab10cd9416db0d442b8cec2949\",\"dependencies\":[],\"protocol_feature_type\":\"builtin\",\"specification\":[{\"name\":\"builtin_feature_codename\",\"value\":\"ONLY_LINK_TO_EXISTING_PERMISSION\"}]}],\"more\":10}" +} \ No newline at end of file