Skip to content

Commit

Permalink
Merge pull request PolymeshAssociation#1155 from PolymeshAssociation/…
Browse files Browse the repository at this point in the history
…nft-locked-err

fix: 🐛 handle NFT locked error in nft.canTransfer
  • Loading branch information
polymath-eric authored Feb 28, 2024
2 parents b92c3c6 + 8230c9c commit 2c78f6c
Show file tree
Hide file tree
Showing 11 changed files with 698 additions and 830 deletions.
3 changes: 2 additions & 1 deletion scripts/transactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@
"dispatch_as": "dispatch_as",
"force_batch": "force_batch",
"with_weight": "with_weight",
"batch_old": "batch_old"
"batch_old": "batch_old",
"as_derivative": "as_derivative"
},
"ExternalAgents": {
"create_group": "create_group",
Expand Down
1 change: 1 addition & 0 deletions src/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ export enum UtilityTx {
ForceBatch = 'utility.forceBatch',
WithWeight = 'utility.withWeight',
BatchOld = 'utility.batchOld',
AsDerivative = 'utility.asDerivative',
}

export enum ExternalAgentsTx {
Expand Down
22 changes: 16 additions & 6 deletions src/polkadot/augment-api-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ declare module '@polkadot/api-base/types/errors' {
* An invalid granularity.
**/
InvalidGranularity: AugmentedError<ApiType>;
/**
* Invalid ticker character - valid set: A`..`Z` `0`..`9` `_` `-` `.` `/`.
**/
InvalidTickerCharacter: AugmentedError<ApiType>;
/**
* Transfer validation check failed.
**/
Expand Down Expand Up @@ -120,6 +124,10 @@ declare module '@polkadot/api-base/types/errors' {
* The asset must be frozen.
**/
NotFrozen: AugmentedError<ApiType>;
/**
* Number of asset mediators would exceed the maximum allowed.
**/
NumberOfAssetMediatorsExceeded: AugmentedError<ApiType>;
/**
* Transfers to self are not allowed
**/
Expand Down Expand Up @@ -1078,6 +1086,10 @@ declare module '@polkadot/api-base/types/errors' {
* Failed to transfer an NFT - the number of nfts in the identity is insufficient.
**/
InvalidNFTTransferInsufficientCount: AugmentedError<ApiType>;
/**
* Failed to transfer an NFT - nft is locked.
**/
InvalidNFTTransferNFTIsLocked: AugmentedError<ApiType>;
/**
* Failed to transfer an NFT - NFT not found in portfolio.
**/
Expand Down Expand Up @@ -1893,12 +1905,6 @@ declare module '@polkadot/api-base/types/errors' {
**/
Unauthorized: AugmentedError<ApiType>;
};
sudo: {
/**
* Sender must be the Sudo account
**/
RequireSudo: AugmentedError<ApiType>;
};
system: {
/**
* The origin filter prevent the call to be dispatched.
Expand Down Expand Up @@ -2104,6 +2110,10 @@ declare module '@polkadot/api-base/types/errors' {
* Too many calls batched.
**/
TooManyCalls: AugmentedError<ApiType>;
/**
* Decoding derivative account Id failed.
**/
UnableToDeriveAccountId: AugmentedError<ApiType>;
};
} // AugmentedErrors
} // declare module
14 changes: 0 additions & 14 deletions src/polkadot/augment-api-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2284,20 +2284,6 @@ declare module '@polkadot/api-base/types/events' {
]
>;
};
sudo: {
/**
* The \[sudoer\] just switched identity; the old key is supplied.
**/
KeyChanged: AugmentedEvent<ApiType, [Option<AccountId32>]>;
/**
* A sudo just took place. \[result\]
**/
Sudid: AugmentedEvent<ApiType, [Result<Null, SpRuntimeDispatchError>]>;
/**
* A sudo just took place. \[result\]
**/
SudoAsDone: AugmentedEvent<ApiType, [Result<Null, SpRuntimeDispatchError>]>;
};
system: {
/**
* `:code` was updated.
Expand Down
14 changes: 4 additions & 10 deletions src/polkadot/augment-api-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ import type {
PolymeshPrimitivesTicker,
PolymeshPrimitivesTransferComplianceAssetTransferCompliance,
PolymeshPrimitivesTransferComplianceTransferConditionExemptKey,
PolymeshRuntimeDevelopRuntimeSessionKeys,
PolymeshRuntimeTestnetRuntimeSessionKeys,
SpConsensusBabeAppPublic,
SpConsensusBabeBabeEpochConfiguration,
SpConsensusBabeDigestsNextConfigDescriptor,
Expand Down Expand Up @@ -1672,7 +1672,7 @@ declare module '@polkadot/api-base/types/storage' {
(
arg1: PolymeshPrimitivesTicker | string | Uint8Array,
arg2: u64 | AnyNumber | Uint8Array
) => Observable<Option<PolymeshPrimitivesIdentityId>>,
) => Observable<Option<PolymeshPrimitivesIdentityIdPortfolioId>>,
[PolymeshPrimitivesTicker, u64]
>;
/**
Expand Down Expand Up @@ -2272,7 +2272,7 @@ declare module '@polkadot/api-base/types/storage' {
ApiType,
(
arg: AccountId32 | string | Uint8Array
) => Observable<Option<PolymeshRuntimeDevelopRuntimeSessionKeys>>,
) => Observable<Option<PolymeshRuntimeTestnetRuntimeSessionKeys>>,
[AccountId32]
>;
/**
Expand All @@ -2286,7 +2286,7 @@ declare module '@polkadot/api-base/types/storage' {
**/
queuedKeys: AugmentedQuery<
ApiType,
() => Observable<Vec<ITuple<[AccountId32, PolymeshRuntimeDevelopRuntimeSessionKeys]>>>,
() => Observable<Vec<ITuple<[AccountId32, PolymeshRuntimeTestnetRuntimeSessionKeys]>>>,
[]
>;
/**
Expand Down Expand Up @@ -2937,12 +2937,6 @@ declare module '@polkadot/api-base/types/storage' {
[PolymeshPrimitivesTicker, u64]
>;
};
sudo: {
/**
* The `AccountId` of the sudo key.
**/
key: AugmentedQuery<ApiType, () => Observable<Option<AccountId32>>, []>;
};
system: {
/**
* The full account information for a particular account ID.
Expand Down
117 changes: 21 additions & 96 deletions src/polkadot/augment-api-tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ import type {
PolymeshPrimitivesTicker,
PolymeshPrimitivesTransferComplianceTransferCondition,
PolymeshPrimitivesTransferComplianceTransferConditionExemptKey,
PolymeshRuntimeDevelopRuntimeOriginCaller,
PolymeshRuntimeDevelopRuntimeSessionKeys,
PolymeshRuntimeTestnetRuntimeOriginCaller,
PolymeshRuntimeTestnetRuntimeSessionKeys,
SpConsensusBabeDigestsNextConfigDescriptor,
SpConsensusGrandpaEquivocationProof,
SpConsensusSlotsEquivocationProof,
Expand Down Expand Up @@ -5151,13 +5151,13 @@ declare module '@polkadot/api-base/types/submittable' {
setKeys: AugmentedSubmittable<
(
keys:
| PolymeshRuntimeDevelopRuntimeSessionKeys
| PolymeshRuntimeTestnetRuntimeSessionKeys
| { grandpa?: any; babe?: any; imOnline?: any; authorityDiscovery?: any }
| string
| Uint8Array,
proof: Bytes | string | Uint8Array
) => SubmittableExtrinsic<ApiType>,
[PolymeshRuntimeDevelopRuntimeSessionKeys, Bytes]
[PolymeshRuntimeTestnetRuntimeSessionKeys, Bytes]
>;
};
settlement: {
Expand Down Expand Up @@ -6870,96 +6870,6 @@ declare module '@polkadot/api-base/types/submittable' {
[PolymeshPrimitivesTicker, u64]
>;
};
sudo: {
/**
* Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key.
*
* The dispatch origin for this call must be _Signed_.
*
* # <weight>
* - O(1).
* - Limited storage reads.
* - One DB change.
* # </weight>
**/
setKey: AugmentedSubmittable<
(
updated:
| MultiAddress
| { Id: any }
| { Index: any }
| { Raw: any }
| { Address32: any }
| { Address20: any }
| string
| Uint8Array
) => SubmittableExtrinsic<ApiType>,
[MultiAddress]
>;
/**
* Authenticates the sudo key and dispatches a function call with `Root` origin.
*
* The dispatch origin for this call must be _Signed_.
*
* # <weight>
* - O(1).
* - Limited storage reads.
* - One DB write (event).
* - Weight of derivative `call` execution + 10,000.
* # </weight>
**/
sudo: AugmentedSubmittable<
(call: Call | IMethod | string | Uint8Array) => SubmittableExtrinsic<ApiType>,
[Call]
>;
/**
* Authenticates the sudo key and dispatches a function call with `Signed` origin from
* a given account.
*
* The dispatch origin for this call must be _Signed_.
*
* # <weight>
* - O(1).
* - Limited storage reads.
* - One DB write (event).
* - Weight of derivative `call` execution + 10,000.
* # </weight>
**/
sudoAs: AugmentedSubmittable<
(
who:
| MultiAddress
| { Id: any }
| { Index: any }
| { Raw: any }
| { Address32: any }
| { Address20: any }
| string
| Uint8Array,
call: Call | IMethod | string | Uint8Array
) => SubmittableExtrinsic<ApiType>,
[MultiAddress, Call]
>;
/**
* Authenticates the sudo key and dispatches a function call with `Root` origin.
* This function does not check the weight of the call, and instead allows the
* Sudo user to specify the weight of the call.
*
* The dispatch origin for this call must be _Signed_.
*
* # <weight>
* - O(1).
* - The weight of this call is defined by the caller.
* # </weight>
**/
sudoUncheckedWeight: AugmentedSubmittable<
(
call: Call | IMethod | string | Uint8Array,
weight: SpWeightsWeightV2Weight | { refTime?: any; proofSize?: any } | string | Uint8Array
) => SubmittableExtrinsic<ApiType>,
[Call, SpWeightsWeightV2Weight]
>;
};
system: {
/**
* Kill all storage items with a key that starts with the given prefix.
Expand Down Expand Up @@ -7548,6 +7458,21 @@ declare module '@polkadot/api-base/types/submittable' {
>;
};
utility: {
/**
* Send a call through an indexed pseudonym of the sender.
*
* Filter from origin are passed along. The call will be dispatched with an origin which
* use the same filter as the origin of this call.
*
* The dispatch origin for this call must be _Signed_.
**/
asDerivative: AugmentedSubmittable<
(
index: u16 | AnyNumber | Uint8Array,
call: Call | IMethod | string | Uint8Array
) => SubmittableExtrinsic<ApiType>,
[u16, Call]
>;
/**
* Send a batch of dispatch calls.
*
Expand Down Expand Up @@ -7694,7 +7619,7 @@ declare module '@polkadot/api-base/types/submittable' {
dispatchAs: AugmentedSubmittable<
(
asOrigin:
| PolymeshRuntimeDevelopRuntimeOriginCaller
| PolymeshRuntimeTestnetRuntimeOriginCaller
| { system: any }
| { Void: any }
| { PolymeshCommittee: any }
Expand All @@ -7704,7 +7629,7 @@ declare module '@polkadot/api-base/types/submittable' {
| Uint8Array,
call: Call | IMethod | string | Uint8Array
) => SubmittableExtrinsic<ApiType>,
[PolymeshRuntimeDevelopRuntimeOriginCaller, Call]
[PolymeshRuntimeTestnetRuntimeOriginCaller, Call]
>;
/**
* Send a batch of dispatch calls.
Expand Down
Loading

0 comments on commit 2c78f6c

Please sign in to comment.