Skip to content

Commit 8b4d387

Browse files
authored
Bump metadata (w/ AssetBalance, AssetDetails) (#2917)
* Bump metadata (w/ AssetBalance, AssetDetails) * Bluperint for new-style with salt as default * Use TBalance * Easier overrides * Balance * Build types
1 parent 4e2ab3d commit 8b4d387

File tree

11 files changed

+1020
-16
lines changed

11 files changed

+1020
-16
lines changed

packages/api-contract/src/base/Blueprint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
9292
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
9393
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
9494
const tx = withSalt
95-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
96-
// @ts-ignore new style with salt included
9795
? this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded, encodedSalt)
96+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
97+
// @ts-ignore old style with salt included
9898
: this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded);
9999

100100
return tx.withResultTransform((result: ISubmittableResult) =>

packages/api/src/augment/query.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import type { Bytes, Data, Option, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
55
import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
6+
import type { AssetBalance, AssetDetails } from '@polkadot/types/interfaces/assets';
67
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
78
import type { BabeAuthorityWeight, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
89
import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances';
@@ -17,7 +18,7 @@ import type { AuthIndex } from '@polkadot/types/interfaces/imOnline';
1718
import type { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
1819
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
1920
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
20-
import type { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, ExtrinsicsWeight, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime';
21+
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, ExtrinsicsWeight, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime';
2122
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
2223
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
2324
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
@@ -31,6 +32,17 @@ import type { ApiTypes } from '@polkadot/api/types';
3132

3233
declare module '@polkadot/api/types/storage' {
3334
export interface AugmentedQueries<ApiType> {
35+
assets: {
36+
[key: string]: QueryableStorageEntry<ApiType>;
37+
/**
38+
* The number of units of assets held by any given account.
39+
**/
40+
account: AugmentedQueryDoubleMap<ApiType, (key1: AssetId | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<AssetBalance>> & QueryableStorageEntry<ApiType>;
41+
/**
42+
* Details of an asset.
43+
**/
44+
asset: AugmentedQuery<ApiType, (arg: AssetId | AnyNumber | Uint8Array) => Observable<Option<AssetDetails>>> & QueryableStorageEntry<ApiType>;
45+
};
3446
authorship: {
3547
[key: string]: QueryableStorageEntry<ApiType>;
3648
/**

packages/api/src/augment/tx.ts

Lines changed: 219 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { GrandpaEquivocationProof, KeyOwnerProof } from '@polkadot/types/in
1313
import type { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity';
1414
import type { Heartbeat } from '@polkadot/types/interfaces/imOnline';
1515
import type { ProxyType } from '@polkadot/types/interfaces/proxy';
16-
import type { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, CallHashOf, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Weight } from '@polkadot/types/interfaces/runtime';
16+
import type { AccountId, AccountIndex, Address, AssetId, Balance, BalanceOf, BlockNumber, Call, CallHashOf, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Weight } from '@polkadot/types/interfaces/runtime';
1717
import type { Period, Priority } from '@polkadot/types/interfaces/scheduler';
1818
import type { Keys } from '@polkadot/types/interfaces/session';
1919
import type { SocietyJudgement } from '@polkadot/types/interfaces/society';
@@ -26,6 +26,216 @@ import type { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types';
2626

2727
declare module '@polkadot/api/types/submittable' {
2828
export interface AugmentedSubmittables<ApiType> {
29+
assets: {
30+
[key: string]: SubmittableExtrinsicFunction<ApiType>;
31+
/**
32+
* Reduce the balance of `who` by as much as possible up to `amount` assets of `id`.
33+
*
34+
* Origin must be Signed and the sender should be the Manager of the asset `id`.
35+
*
36+
* Bails with `BalanceZero` if the `who` is already dead.
37+
*
38+
* - `id`: The identifier of the asset to have some amount burned.
39+
* - `who`: The account to be debited from.
40+
* - `amount`: The maximum amount by which `who`'s balance should be reduced.
41+
*
42+
* Emits `Burned` with the actual amount burned. If this takes the balance to below the
43+
* minimum for the asset, then the amount burned is increased to take it to zero.
44+
*
45+
* Weight: `O(1)`
46+
* Modes: Post-existence of `who`; Pre & post Zombie-status of `who`.
47+
**/
48+
burn: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
49+
/**
50+
* Issue a new class of fungible assets from a public origin.
51+
*
52+
* This new asset class has no assets initially.
53+
*
54+
* The origin must be Signed and the sender must have sufficient funds free.
55+
*
56+
* Funds of sender are reserved according to the formula:
57+
* `AssetDepositBase + AssetDepositPerZombie * max_zombies`.
58+
*
59+
* Parameters:
60+
* - `id`: The identifier of the new asset. This must not be currently in use to identify
61+
* an existing asset.
62+
* - `owner`: The owner of this class of assets. The owner has full superuser permissions
63+
* over this asset, but may later change and configure the permissions using `transfer_ownership`
64+
* and `set_team`.
65+
* - `max_zombies`: The total number of accounts which may hold assets in this class yet
66+
* have no existential deposit.
67+
* - `min_balance`: The minimum balance of this new asset that any single account must
68+
* have. If an account's balance is reduced below this, then it collapses to zero.
69+
*
70+
* Emits `Created` event when successful.
71+
*
72+
* Weight: `O(1)`
73+
**/
74+
create: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, admin: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, maxZombies: u32 | AnyNumber | Uint8Array, minBalance: Balance | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
75+
/**
76+
* Destroy a class of fungible assets owned by the sender.
77+
*
78+
* The origin must be Signed and the sender must be the owner of the asset `id`.
79+
*
80+
* - `id`: The identifier of the asset to be destroyed. This must identify an existing
81+
* asset.
82+
*
83+
* Emits `Destroyed` event when successful.
84+
*
85+
* Weight: `O(z)` where `z` is the number of zombie accounts.
86+
**/
87+
destroy: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, zombiesWitness: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
88+
/**
89+
* Issue a new class of fungible assets from a privileged origin.
90+
*
91+
* This new asset class has no assets initially.
92+
*
93+
* The origin must conform to `ForceOrigin`.
94+
*
95+
* Unlike `create`, no funds are reserved.
96+
*
97+
* - `id`: The identifier of the new asset. This must not be currently in use to identify
98+
* an existing asset.
99+
* - `owner`: The owner of this class of assets. The owner has full superuser permissions
100+
* over this asset, but may later change and configure the permissions using `transfer_ownership`
101+
* and `set_team`.
102+
* - `max_zombies`: The total number of accounts which may hold assets in this class yet
103+
* have no existential deposit.
104+
* - `min_balance`: The minimum balance of this new asset that any single account must
105+
* have. If an account's balance is reduced below this, then it collapses to zero.
106+
*
107+
* Emits `ForceCreated` event when successful.
108+
*
109+
* Weight: `O(1)`
110+
**/
111+
forceCreate: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array, minBalance: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
112+
/**
113+
* Destroy a class of fungible assets.
114+
*
115+
* The origin must conform to `ForceOrigin`.
116+
*
117+
* - `id`: The identifier of the asset to be destroyed. This must identify an existing
118+
* asset.
119+
*
120+
* Emits `Destroyed` event when successful.
121+
*
122+
* Weight: `O(1)`
123+
**/
124+
forceDestroy: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, zombiesWitness: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
125+
/**
126+
* Move some assets from one account to another.
127+
*
128+
* Origin must be Signed and the sender should be the Admin of the asset `id`.
129+
*
130+
* - `id`: The identifier of the asset to have some amount transferred.
131+
* - `source`: The account to be debited.
132+
* - `dest`: The account to be credited.
133+
* - `amount`: The amount by which the `source`'s balance of assets should be reduced and
134+
* `dest`'s balance increased. The amount actually transferred may be slightly greater in
135+
* the case that the transfer would otherwise take the `source` balance above zero but
136+
* below the minimum balance. Must be greater than zero.
137+
*
138+
* Emits `Transferred` with the actual amount transferred. If this takes the source balance
139+
* to below the minimum for the asset, then the amount transferred is increased to take it
140+
* to zero.
141+
*
142+
* Weight: `O(1)`
143+
* Modes: Pre-existence of `dest`; Post-existence of `source`; Prior & post zombie-status
144+
* of `source`; Account pre-existence of `dest`.
145+
**/
146+
forceTransfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
147+
/**
148+
* Disallow further unprivileged transfers from an account.
149+
*
150+
* Origin must be Signed and the sender should be the Freezer of the asset `id`.
151+
*
152+
* - `id`: The identifier of the asset to be frozen.
153+
* - `who`: The account to be frozen.
154+
*
155+
* Emits `Frozen`.
156+
*
157+
* Weight: `O(1)`
158+
**/
159+
freeze: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
160+
/**
161+
* Mint assets of a particular class.
162+
*
163+
* The origin must be Signed and the sender must be the Issuer of the asset `id`.
164+
*
165+
* - `id`: The identifier of the asset to have some amount minted.
166+
* - `beneficiary`: The account to be credited with the minted assets.
167+
* - `amount`: The amount of the asset to be minted.
168+
*
169+
* Emits `Destroyed` event when successful.
170+
*
171+
* Weight: `O(1)`
172+
* Modes: Pre-existing balance of `beneficiary`; Account pre-existence of `beneficiary`.
173+
**/
174+
mint: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
175+
setMaxZombies: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
176+
/**
177+
* Change the Issuer, Admin and Freezer of an asset.
178+
*
179+
* Origin must be Signed and the sender should be the Owner of the asset `id`.
180+
*
181+
* - `id`: The identifier of the asset to be frozen.
182+
* - `issuer`: The new Issuer of this asset.
183+
* - `admin`: The new Admin of this asset.
184+
* - `freezer`: The new Freezer of this asset.
185+
*
186+
* Emits `TeamChanged`.
187+
*
188+
* Weight: `O(1)`
189+
**/
190+
setTeam: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, issuer: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, admin: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, freezer: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
191+
/**
192+
* Allow unprivileged transfers from an account again.
193+
*
194+
* Origin must be Signed and the sender should be the Admin of the asset `id`.
195+
*
196+
* - `id`: The identifier of the asset to be frozen.
197+
* - `who`: The account to be unfrozen.
198+
*
199+
* Emits `Thawed`.
200+
*
201+
* Weight: `O(1)`
202+
**/
203+
thaw: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
204+
/**
205+
* Move some assets from the sender account to another.
206+
*
207+
* Origin must be Signed.
208+
*
209+
* - `id`: The identifier of the asset to have some amount transferred.
210+
* - `target`: The account to be credited.
211+
* - `amount`: The amount by which the sender's balance of assets should be reduced and
212+
* `target`'s balance increased. The amount actually transferred may be slightly greater in
213+
* the case that the transfer would otherwise take the sender balance above zero but below
214+
* the minimum balance. Must be greater than zero.
215+
*
216+
* Emits `Transferred` with the actual amount transferred. If this takes the source balance
217+
* to below the minimum for the asset, then the amount transferred is increased to take it
218+
* to zero.
219+
*
220+
* Weight: `O(1)`
221+
* Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
222+
* of sender; Account pre-existence of `target`.
223+
**/
224+
transfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
225+
/**
226+
* Change the Owner of an asset.
227+
*
228+
* Origin must be Signed and the sender should be the Owner of the asset `id`.
229+
*
230+
* - `id`: The identifier of the asset to be frozen.
231+
* - `owner`: The new Owner of this asset.
232+
*
233+
* Emits `OwnerChanged`.
234+
*
235+
* Weight: `O(1)`
236+
**/
237+
transferOwnership: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
238+
};
29239
authorship: {
30240
[key: string]: SubmittableExtrinsicFunction<ApiType>;
31241
/**
@@ -152,18 +362,21 @@ declare module '@polkadot/api/types/submittable' {
152362
**/
153363
claimSurcharge: AugmentedSubmittable<(dest: AccountId | string | Uint8Array, auxSender: Option<AccountId> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
154364
/**
155-
* Instantiates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance.
365+
* Instantiates a new contract from the `code_hash` generated by `put_code`,
366+
* optionally transferring some balance.
367+
*
368+
* The supplied `salt` is used for contract address deriviation. See `fn contract_address`.
156369
*
157370
* Instantiation is executed as follows:
158371
*
159-
* - The destination address is computed based on the sender and hash of the code.
372+
* - The destination address is computed based on the sender, code_hash and the salt.
160373
* - The smart-contract account is created at the computed address.
161374
* - The `ctor_code` is executed in the context of the newly-created account. Buffer returned
162375
* after the execution is saved as the `code` of the account. That code will be invoked
163376
* upon any call received by this account.
164377
* - The contract is initialized.
165378
**/
166-
instantiate: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, codeHash: CodeHash | string | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
379+
instantiate: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, codeHash: CodeHash | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
167380
/**
168381
* Stores the given binary Wasm code into the chain's storage and returns its `codehash`.
169382
* You can instantiate contracts only with stored code.
@@ -3339,7 +3552,7 @@ declare module '@polkadot/api/types/submittable' {
33393552
* - `calls`: The calls to be dispatched from the same origin.
33403553
*
33413554
* If origin is root then call are dispatch without checking origin filter. (This includes
3342-
* bypassing `frame_system::Trait::BaseCallFilter`).
3555+
* bypassing `frame_system::Config::BaseCallFilter`).
33433556
*
33443557
* # <weight>
33453558
* - Complexity: O(C) where C is the number of calls to be batched.
@@ -3361,7 +3574,7 @@ declare module '@polkadot/api/types/submittable' {
33613574
* - `calls`: The calls to be dispatched from the same origin.
33623575
*
33633576
* If origin is root then call are dispatch without checking origin filter. (This includes
3364-
* bypassing `frame_system::Trait::BaseCallFilter`).
3577+
* bypassing `frame_system::Config::BaseCallFilter`).
33653578
*
33663579
* # <weight>
33673580
* - Complexity: O(C) where C is the number of calls to be batched.

0 commit comments

Comments
 (0)