Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
db3822d
adds definitions and types according to ink v5 changes
peetzweg Feb 1, 2024
9f93a19
adds toV5 boilerplate code draft
peetzweg Feb 1, 2024
0cf749e
adds v5 flipper test contract code
peetzweg Feb 1, 2024
cfba268
fix license dates
peetzweg Feb 1, 2024
7d404f4
adds test v5 toLatest test
peetzweg Feb 1, 2024
1f9e6f5
implements new scheme to determine event
peetzweg Feb 1, 2024
985365f
apply linter changes
peetzweg Feb 1, 2024
5db72af
adds test result outputs
peetzweg Feb 1, 2024
cc946da
change `EventRecord['topics'][0]` type to plain `Hash`
peetzweg Feb 16, 2024
54fd609
adds testcases for decoding payload data of a ink!v4 and ink!v5 event
peetzweg Feb 23, 2024
013ea59
changes `Abi.decodeEvent(data:Bytes)` method interface to `Abi.decode…
peetzweg Feb 26, 2024
a028c55
draft implementation with version metadata
peetzweg Feb 26, 2024
3e0d8d1
cleaner implementation of versioned Metadata by actually leveraging t…
peetzweg Feb 27, 2024
ada84b3
Merge branch 'polkadot-js:master' into pz/ink-v5
peetzweg Feb 27, 2024
0029e18
trying to make linter happy
peetzweg Feb 27, 2024
f000f24
Merge branch 'pz/ink-v5' of github.com:peetzweg/pjs-api into pz/ink-v5
peetzweg Feb 27, 2024
0124e14
makes `ContractMetadataSupported` in internal to `Abi` type and not e…
peetzweg Feb 27, 2024
fcb684d
properly types unused parameter for tsc :shrug:
peetzweg Feb 27, 2024
64feb63
adds `@polkadot/types-support` dev dependency
peetzweg Feb 27, 2024
df9956c
merge master
peetzweg Feb 27, 2024
f1a1b9d
Update yarn.lock
peetzweg Feb 27, 2024
1cda4b9
references `types-support` in `api-contract
peetzweg Feb 27, 2024
246570d
resolving change requests
peetzweg Feb 28, 2024
f88fcf7
resolves linter warnings
peetzweg Feb 28, 2024
f67a88a
changes ContractMetadataV5 field to `u64` from `Text`
peetzweg Feb 28, 2024
27d6b46
adds contracts and contract metadata compiled with the most recent in…
peetzweg Feb 28, 2024
0e039e7
implements decoding of anonymous events if possible
peetzweg Mar 1, 2024
3b48940
removes done todo comments
peetzweg Mar 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adds toV5 boilerplate code draft
  • Loading branch information
peetzweg committed Feb 1, 2024
commit 9f93a19b451b8327d379a2ea5cedf8d28160b05e
11 changes: 7 additions & 4 deletions packages/api-contract/src/Abi/toLatest.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// Copyright 2017-2024 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { ContractMetadataLatest, ContractMetadataV4 } from '@polkadot/types/interfaces';
import type { ContractMetadataLatest, ContractMetadataV5 } from '@polkadot/types/interfaces';
import type { Registry } from '@polkadot/types/types';

import { v0ToV1 } from './toV1.js';
import { v1ToV2 } from './toV2.js';
import { v2ToV3 } from './toV3.js';
import { v3ToV4 } from './toV4.js';
import { v4ToV5 } from './toV5.js';

// The versions where an enum is used, aka V0 is missing
// (Order from newest, i.e. we expect more on newest vs oldest)
export const enumVersions = ['V4', 'V3', 'V2', 'V1'] as const;
export const enumVersions = ['V5', 'V4', 'V3', 'V2', 'V1'] as const;

type Versions = typeof enumVersions[number] | 'V0';

Expand All @@ -23,16 +24,18 @@ function createConverter <I, O> (next: (registry: Registry, input: O) => Contrac
next(registry, step(registry, input));
}

export function v4ToLatest (_registry: Registry, v4: ContractMetadataV4): ContractMetadataLatest {
return v4;
export function v5ToLatest (_registry: Registry, v5: ContractMetadataV5): ContractMetadataLatest {
return v5;
}

export const v4ToLatest = /*#__PURE__*/ createConverter(v5ToLatest, v4ToV5);
export const v3ToLatest = /*#__PURE__*/ createConverter(v4ToLatest, v3ToV4);
export const v2ToLatest = /*#__PURE__*/ createConverter(v3ToLatest, v2ToV3);
export const v1ToLatest = /*#__PURE__*/ createConverter(v2ToLatest, v1ToV2);
export const v0ToLatest = /*#__PURE__*/ createConverter(v1ToLatest, v0ToV1);

export const convertVersions: [Versions, Converter][] = [
['V5', v5ToLatest],
['V4', v4ToLatest],
['V3', v3ToLatest],
['V2', v2ToLatest],
Expand Down
20 changes: 20 additions & 0 deletions packages/api-contract/src/Abi/toV5.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2017-2023 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { ContractMetadataV4, ContractMetadataV5 } from '@polkadot/types/interfaces';
import type { Registry } from '@polkadot/types/types';

import { objectSpread } from '@polkadot/util';

export function v4ToV5 (registry: Registry, v4: ContractMetadataV4): ContractMetadataV5 {
return registry.createType('ContractMetadataV5', objectSpread({}, v4, {
spec: objectSpread({}, v4.spec, {
events: v4.spec.events.map((e) =>
registry.createType('ContractEventSpecV3', objectSpread({
module_path: 'todo::todo',
signature_topic: "0xDEADBEEF"
}, e))
)
})
}));
}