@pezkuwi/api-contract 16.5.5 → 16.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Abi/index.js +359 -0
- package/Abi/toLatestCompatible.js +30 -0
- package/Abi/toV1.js +21 -0
- package/Abi/toV2.js +27 -0
- package/Abi/toV3.js +10 -0
- package/Abi/toV4.js +10 -0
- package/LICENSE +201 -0
- package/README.md +1 -1
- package/augment.js +1 -0
- package/base/Base.js +40 -0
- package/base/Blueprint.js +51 -0
- package/base/Code.js +74 -0
- package/base/Contract.js +127 -0
- package/{src/base/index.ts → base/index.js} +0 -3
- package/base/mock.js +38 -0
- package/{build/base → base}/util.d.ts +1 -1
- package/base/util.js +33 -0
- package/bundle-pezkuwi-api-contract.js +1238 -0
- package/{src/bundle.ts → bundle.js} +0 -6
- package/cjs/Abi/index.d.ts +31 -0
- package/cjs/Abi/index.js +363 -0
- package/cjs/Abi/toLatestCompatible.d.ts +15 -0
- package/cjs/Abi/toLatestCompatible.js +36 -0
- package/cjs/Abi/toV1.d.ts +3 -0
- package/cjs/Abi/toV1.js +24 -0
- package/cjs/Abi/toV2.d.ts +3 -0
- package/cjs/Abi/toV2.js +30 -0
- package/cjs/Abi/toV3.d.ts +3 -0
- package/cjs/Abi/toV3.js +13 -0
- package/cjs/Abi/toV4.d.ts +3 -0
- package/cjs/Abi/toV4.js +13 -0
- package/cjs/augment.d.ts +1 -0
- package/cjs/augment.js +3 -0
- package/cjs/base/Base.d.ts +13 -0
- package/cjs/base/Base.js +44 -0
- package/cjs/base/Blueprint.d.ts +24 -0
- package/cjs/base/Blueprint.js +57 -0
- package/cjs/base/Code.d.ts +22 -0
- package/cjs/base/Code.js +80 -0
- package/cjs/base/Contract.d.ts +25 -0
- package/cjs/base/Contract.js +133 -0
- package/cjs/base/index.d.ts +3 -0
- package/cjs/base/index.js +14 -0
- package/cjs/base/mock.d.ts +3 -0
- package/cjs/base/mock.js +41 -0
- package/{src/base/types.ts → cjs/base/types.d.ts} +6 -21
- package/cjs/base/types.js +2 -0
- package/cjs/base/util.d.ts +16 -0
- package/cjs/base/util.js +42 -0
- package/cjs/bundle.d.ts +4 -0
- package/cjs/bundle.js +10 -0
- package/cjs/index.js +5 -0
- package/cjs/package.json +3 -0
- package/cjs/packageDetect.d.ts +1 -0
- package/cjs/packageDetect.js +7 -0
- package/cjs/packageInfo.js +4 -0
- package/cjs/promise/index.js +23 -0
- package/cjs/promise/types.js +2 -0
- package/cjs/rx/index.js +23 -0
- package/cjs/rx/types.js +2 -0
- package/cjs/types.js +2 -0
- package/cjs/util.js +13 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +384 -15
- package/packageDetect.d.ts +1 -0
- package/{src/packageDetect.ts → packageDetect.js} +0 -8
- package/packageInfo.d.ts +6 -0
- package/packageInfo.js +1 -0
- package/promise/index.d.ts +13 -0
- package/promise/index.js +17 -0
- package/{src/promise/types.ts → promise/types.d.ts} +0 -4
- package/promise/types.js +1 -0
- package/rx/index.d.ts +13 -0
- package/rx/index.js +17 -0
- package/{src/rx/types.ts → rx/types.d.ts} +0 -4
- package/rx/types.js +1 -0
- package/types.d.ts +79 -0
- package/types.js +1 -0
- package/util.d.ts +5 -0
- package/util.js +10 -0
- package/src/Abi/Abi.spec.ts +0 -235
- package/src/Abi/index.ts +0 -477
- package/src/Abi/toLatestCompatible.spec.ts +0 -219
- package/src/Abi/toLatestCompatible.ts +0 -52
- package/src/Abi/toV1.ts +0 -35
- package/src/Abi/toV2.ts +0 -58
- package/src/Abi/toV3.ts +0 -18
- package/src/Abi/toV4.ts +0 -21
- package/src/augment.ts +0 -4
- package/src/base/Base.ts +0 -52
- package/src/base/Blueprint.ts +0 -90
- package/src/base/Code.spec.ts +0 -47
- package/src/base/Code.ts +0 -142
- package/src/base/Contract.ts +0 -197
- package/src/base/mock.ts +0 -48
- package/src/base/util.ts +0 -56
- package/src/checkTypes.manual.ts +0 -45
- package/src/index.ts +0 -6
- package/src/mod.ts +0 -4
- package/src/packageInfo.ts +0 -6
- package/src/promise/index.ts +0 -28
- package/src/rx/index.ts +0 -28
- package/src/test/compare/ink_v0_delegator.test.json +0 -47
- package/src/test/compare/ink_v0_dns.test.json +0 -232
- package/src/test/compare/ink_v0_erc20.test.json +0 -253
- package/src/test/compare/ink_v0_erc721.test.json +0 -415
- package/src/test/compare/ink_v0_flipper.test.json +0 -9
- package/src/test/compare/ink_v0_flipperBundle.test.json +0 -9
- package/src/test/compare/ink_v0_incrementer.test.json +0 -9
- package/src/test/compare/ink_v0_multisigPlain.test.json +0 -562
- package/src/test/compare/ink_v1_flipper.test.json +0 -9
- package/src/test/compare/ink_v1_psp22.test.json +0 -531
- package/src/test/compare/ink_v2_erc20.test.json +0 -205
- package/src/test/compare/ink_v2_flipper.test.json +0 -9
- package/src/test/compare/ink_v3_flipper.test.json +0 -9
- package/src/test/compare/ink_v3_traitErc20.test.json +0 -205
- package/src/test/compare/ink_v4_erc20Contract.test.json +0 -253
- package/src/test/compare/ink_v4_erc20Metadata.test.json +0 -253
- package/src/test/compare/ink_v4_flipperContract.test.json +0 -155
- package/src/test/compare/ink_v4_flipperMetadata.test.json +0 -155
- package/src/test/compare/ink_v5_erc20.test.json +0 -370
- package/src/test/compare/ink_v5_erc20AnonymousTransferMetadata.test.json +0 -370
- package/src/test/compare/ink_v5_erc20Contract.test.json +0 -370
- package/src/test/compare/ink_v5_erc20Metadata.test.json +0 -370
- package/src/test/compare/ink_v5_flipperContract.test.json +0 -174
- package/src/test/compare/ink_v5_flipperMetadata.test.json +0 -174
- package/src/test/compare/ink_v6_erc20Contract.test.json +0 -418
- package/src/test/compare/ink_v6_erc20Metadata.test.json +0 -418
- package/src/test/compare/solang_v0_ints256.test.json +0 -9
- package/src/test/compare/user_v0_assetTransfer.test.json +0 -54
- package/src/test/compare/user_v0_enumExample.test.json +0 -303
- package/src/test/compare/user_v0_recursive.test.json +0 -27
- package/src/test/compare/user_v0_withString.test.json +0 -260
- package/src/test/compare/user_v3_ask.test.json +0 -71
- package/src/test/compare/user_v4_events.test.json +0 -1328
- package/src/test/contracts/index.ts +0 -20
- package/src/test/contracts/ink/index.ts +0 -13
- package/src/test/contracts/ink/v0/accumulator.wasm +0 -0
- package/src/test/contracts/ink/v0/adder.wasm +0 -0
- package/src/test/contracts/ink/v0/delegator.json +0 -252
- package/src/test/contracts/ink/v0/delegator.wasm +0 -0
- package/src/test/contracts/ink/v0/dns.json +0 -713
- package/src/test/contracts/ink/v0/dns.wasm +0 -0
- package/src/test/contracts/ink/v0/erc20.json +0 -704
- package/src/test/contracts/ink/v0/erc20.wasm +0 -0
- package/src/test/contracts/ink/v0/erc721.json +0 -1197
- package/src/test/contracts/ink/v0/erc721.wasm +0 -0
- package/src/test/contracts/ink/v0/flipper.contract.json +0 -107
- package/src/test/contracts/ink/v0/flipper.json +0 -106
- package/src/test/contracts/ink/v0/flipper.wasm +0 -0
- package/src/test/contracts/ink/v0/incrementer.json +0 -108
- package/src/test/contracts/ink/v0/incrementer.wasm +0 -0
- package/src/test/contracts/ink/v0/index.ts +0 -11
- package/src/test/contracts/ink/v0/multisig_plain.json +0 -1466
- package/src/test/contracts/ink/v0/multisig_plain.wasm +0 -0
- package/src/test/contracts/ink/v0/subber.wasm +0 -0
- package/src/test/contracts/ink/v0/trait-flipper.json +0 -103
- package/src/test/contracts/ink/v0/trait-flipper.wasm +0 -0
- package/src/test/contracts/ink/v1/flipper.contract.json +0 -111
- package/src/test/contracts/ink/v1/index.ts +0 -6
- package/src/test/contracts/ink/v1/psp22_minter_pauser.contract.json +0 -1722
- package/src/test/contracts/ink/v2/erc20.contract.json +0 -630
- package/src/test/contracts/ink/v2/flipper.contract.json +0 -103
- package/src/test/contracts/ink/v2/index.ts +0 -5
- package/src/test/contracts/ink/v3/flipper.contract.json +0 -105
- package/src/test/contracts/ink/v3/index.ts +0 -6
- package/src/test/contracts/ink/v3/trait_erc20.contract.json +0 -631
- package/src/test/contracts/ink/v4/erc20.contract.json +0 -1
- package/src/test/contracts/ink/v4/erc20.json +0 -821
- package/src/test/contracts/ink/v4/erc20.wasm +0 -0
- package/src/test/contracts/ink/v4/flipper.contract.json +0 -1
- package/src/test/contracts/ink/v4/flipper.json +0 -396
- package/src/test/contracts/ink/v4/flipper.wasm +0 -0
- package/src/test/contracts/ink/v4/index.ts +0 -7
- package/src/test/contracts/ink/v5/erc20.contract.json +0 -1
- package/src/test/contracts/ink/v5/erc20.json +0 -1025
- package/src/test/contracts/ink/v5/erc20.wasm +0 -0
- package/src/test/contracts/ink/v5/erc20_anonymous_transfer.json +0 -1025
- package/src/test/contracts/ink/v5/flipper.contract.json +0 -1
- package/src/test/contracts/ink/v5/flipper.json +0 -420
- package/src/test/contracts/ink/v5/flipper.wasm +0 -0
- package/src/test/contracts/ink/v5/index.ts +0 -8
- package/src/test/contracts/ink/v6/erc20.contract.json +0 -1
- package/src/test/contracts/ink/v6/erc20.json +0 -1081
- package/src/test/contracts/ink/v6/erc20.polkavm +0 -0
- package/src/test/contracts/ink/v6/index.ts +0 -5
- package/src/test/contracts/solang/index.ts +0 -7
- package/src/test/contracts/solang/v0/index.ts +0 -4
- package/src/test/contracts/solang/v0/ints256.json +0 -113
- package/src/test/contracts/solang/v0/ints256.sol +0 -13
- package/src/test/contracts/solang/v0/ints256.wasm +0 -0
- package/src/test/contracts/user/index.ts +0 -9
- package/src/test/contracts/user/v0/assetTransfer.json +0 -299
- package/src/test/contracts/user/v0/assetTransfer.wasm +0 -0
- package/src/test/contracts/user/v0/enumExample.json +0 -528
- package/src/test/contracts/user/v0/enumExample.wasm +0 -0
- package/src/test/contracts/user/v0/index.ts +0 -7
- package/src/test/contracts/user/v0/recursive.contract.json +0 -1
- package/src/test/contracts/user/v0/withString.json +0 -777
- package/src/test/contracts/user/v3/ask.json +0 -550
- package/src/test/contracts/user/v3/index.ts +0 -4
- package/src/test/contracts/user/v4/events.contract.json +0 -2990
- package/src/test/contracts/user/v4/index.ts +0 -4
- package/src/test/contracts/util.ts +0 -14
- package/src/types.ts +0 -98
- package/src/util.ts +0 -20
- package/tsconfig.build.json +0 -22
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.spec.json +0 -26
- /package/{build/Abi → Abi}/index.d.ts +0 -0
- /package/{build/Abi → Abi}/toLatestCompatible.d.ts +0 -0
- /package/{build/Abi → Abi}/toV1.d.ts +0 -0
- /package/{build/Abi → Abi}/toV2.d.ts +0 -0
- /package/{build/Abi → Abi}/toV3.d.ts +0 -0
- /package/{build/Abi → Abi}/toV4.d.ts +0 -0
- /package/{build/augment.d.ts → augment.d.ts} +0 -0
- /package/{build/base → base}/Base.d.ts +0 -0
- /package/{build/base → base}/Blueprint.d.ts +0 -0
- /package/{build/base → base}/Code.d.ts +0 -0
- /package/{build/base → base}/Contract.d.ts +0 -0
- /package/{build/base → base}/index.d.ts +0 -0
- /package/{build/base → base}/mock.d.ts +0 -0
- /package/{build/base → base}/types.d.ts +0 -0
- /package/{build/packageDetect.d.ts → base/types.js} +0 -0
- /package/{build/bundle.d.ts → bundle.d.ts} +0 -0
- /package/{build → cjs}/index.d.ts +0 -0
- /package/{build → cjs}/packageInfo.d.ts +0 -0
- /package/{build → cjs}/promise/index.d.ts +0 -0
- /package/{build → cjs}/promise/types.d.ts +0 -0
- /package/{build → cjs}/rx/index.d.ts +0 -0
- /package/{build → cjs}/rx/types.d.ts +0 -0
- /package/{build → cjs}/types.d.ts +0 -0
- /package/{build → cjs}/util.d.ts +0 -0
package/Abi/index.js
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { Option, TypeRegistry } from '@pezkuwi/types';
|
|
2
|
+
import { TypeDefInfo } from '@pezkuwi/types-create';
|
|
3
|
+
import { assertReturn, compactAddLength, compactStripLength, isBn, isNumber, isObject, isString, isUndefined, logger, stringCamelCase, stringify, u8aConcat, u8aToHex } from '@pezkuwi/util';
|
|
4
|
+
import { convertVersions, enumVersions } from './toLatestCompatible.js';
|
|
5
|
+
const l = logger('Abi');
|
|
6
|
+
const PRIMITIVE_ALWAYS = ['AccountId', 'AccountId20', 'AccountIndex', 'Address', 'Balance'];
|
|
7
|
+
function findMessage(list, messageOrId) {
|
|
8
|
+
const message = isNumber(messageOrId)
|
|
9
|
+
? list[messageOrId]
|
|
10
|
+
: isString(messageOrId)
|
|
11
|
+
? list.find(({ identifier }) => [identifier, stringCamelCase(identifier)].includes(messageOrId.toString()))
|
|
12
|
+
: messageOrId;
|
|
13
|
+
return assertReturn(message, () => `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
|
|
14
|
+
}
|
|
15
|
+
function getMetadata(registry, json) {
|
|
16
|
+
// this is for V1, V2, V3
|
|
17
|
+
const vx = enumVersions.find((v) => isObject(json[v]));
|
|
18
|
+
// this was added in V4
|
|
19
|
+
const jsonVersion = json.version;
|
|
20
|
+
if (!vx && jsonVersion && !enumVersions.find((v) => v === `V${jsonVersion}`)) {
|
|
21
|
+
throw new Error(`Unable to handle version ${jsonVersion}`);
|
|
22
|
+
}
|
|
23
|
+
const metadata = registry.createType('ContractMetadata', vx
|
|
24
|
+
? { [vx]: json[vx] }
|
|
25
|
+
: jsonVersion
|
|
26
|
+
? { [`V${jsonVersion}`]: json }
|
|
27
|
+
: { V0: json });
|
|
28
|
+
const converter = convertVersions.find(([v]) => metadata[`is${v}`]);
|
|
29
|
+
if (!converter) {
|
|
30
|
+
throw new Error(`Unable to convert ABI with version ${metadata.type} to a supported version`);
|
|
31
|
+
}
|
|
32
|
+
const upgradedMetadata = converter[1](registry, metadata[`as${converter[0]}`]);
|
|
33
|
+
return upgradedMetadata;
|
|
34
|
+
}
|
|
35
|
+
function isRevive(json) {
|
|
36
|
+
const source = json['source'];
|
|
37
|
+
const version = json['version'];
|
|
38
|
+
const hasContractBinary = typeof source === 'object' &&
|
|
39
|
+
source !== null &&
|
|
40
|
+
'contract_binary' in source;
|
|
41
|
+
const hasVersion = typeof version === 'number' && version >= 6;
|
|
42
|
+
return hasContractBinary || hasVersion;
|
|
43
|
+
}
|
|
44
|
+
function parseJson(json, chainProperties) {
|
|
45
|
+
const registry = new TypeRegistry();
|
|
46
|
+
const revive = isRevive(json);
|
|
47
|
+
const typeName = revive ? 'ContractReviveProjectInfo' : 'ContractProjectInfo';
|
|
48
|
+
const info = registry.createType(typeName, json);
|
|
49
|
+
const metadata = getMetadata(registry, json);
|
|
50
|
+
const lookup = registry.createType('PortableRegistry', { types: metadata.types }, true);
|
|
51
|
+
// attach the lookup to the registry - now the types are known
|
|
52
|
+
registry.setLookup(lookup);
|
|
53
|
+
if (chainProperties) {
|
|
54
|
+
registry.setChainProperties(chainProperties);
|
|
55
|
+
}
|
|
56
|
+
// warm-up the actual type, pre-use
|
|
57
|
+
lookup.types.forEach(({ id }) => lookup.getTypeDef(id));
|
|
58
|
+
return [json, registry, metadata, info, revive];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
* Determines if the given input value is a ContractTypeSpec
|
|
63
|
+
*/
|
|
64
|
+
function isTypeSpec(value) {
|
|
65
|
+
return !!value && value instanceof Map && !isUndefined(value.type) && !isUndefined(value.displayName);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
* Determines if the given input value is an Option
|
|
70
|
+
*/
|
|
71
|
+
function isOption(value) {
|
|
72
|
+
return !!value && value instanceof Option;
|
|
73
|
+
}
|
|
74
|
+
export class Abi {
|
|
75
|
+
events;
|
|
76
|
+
constructors;
|
|
77
|
+
info;
|
|
78
|
+
json;
|
|
79
|
+
messages;
|
|
80
|
+
metadata;
|
|
81
|
+
registry;
|
|
82
|
+
environment = new Map();
|
|
83
|
+
isRevive;
|
|
84
|
+
constructor(abiJson, chainProperties) {
|
|
85
|
+
[this.json, this.registry, this.metadata, this.info, this.isRevive] = parseJson(isString(abiJson)
|
|
86
|
+
? JSON.parse(abiJson)
|
|
87
|
+
: abiJson, chainProperties);
|
|
88
|
+
this.constructors = this.metadata.spec.constructors.map((spec, index) => this.#createMessage(spec, index, {
|
|
89
|
+
isConstructor: true,
|
|
90
|
+
isDefault: spec.default.isTrue,
|
|
91
|
+
isPayable: spec.payable.isTrue,
|
|
92
|
+
returnType: spec.returnType.isSome
|
|
93
|
+
? this.registry.lookup.getTypeDef(spec.returnType.unwrap().type)
|
|
94
|
+
: null
|
|
95
|
+
}));
|
|
96
|
+
this.events = this.metadata.spec.events.map((_, index) => this.#createEvent(index));
|
|
97
|
+
this.messages = this.metadata.spec.messages.map((spec, index) => this.#createMessage(spec, index, {
|
|
98
|
+
isDefault: spec.default.isTrue,
|
|
99
|
+
isMutating: spec.mutates.isTrue,
|
|
100
|
+
isPayable: spec.payable.isTrue,
|
|
101
|
+
returnType: spec.returnType.isSome
|
|
102
|
+
? this.registry.lookup.getTypeDef(spec.returnType.unwrap().type)
|
|
103
|
+
: null
|
|
104
|
+
}));
|
|
105
|
+
// NOTE See the rationale for having Option<...> values in the actual
|
|
106
|
+
// ContractEnvironmentV4 structure definition in interfaces/contractsAbi
|
|
107
|
+
// (Due to conversions, the fields may not exist)
|
|
108
|
+
for (const [key, opt] of this.metadata.spec.environment.entries()) {
|
|
109
|
+
if (isOption(opt)) {
|
|
110
|
+
if (opt.isSome) {
|
|
111
|
+
const value = opt.unwrap();
|
|
112
|
+
if (isBn(value)) {
|
|
113
|
+
this.environment.set(key, value);
|
|
114
|
+
}
|
|
115
|
+
else if (isTypeSpec(value)) {
|
|
116
|
+
this.environment.set(key, this.registry.lookup.getTypeDef(value.type));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw new Error(`Invalid environment definition for ${key}:: Expected either Number or ContractTypeSpec`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
throw new Error(`Expected Option<*> definition for ${key} in ContractEnvironment`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Warning: Unstable API, bound to change
|
|
130
|
+
*/
|
|
131
|
+
decodeEvent(record) {
|
|
132
|
+
switch (this.metadata.version.toString()) {
|
|
133
|
+
// earlier version are hoisted to v4
|
|
134
|
+
case '4':
|
|
135
|
+
return this.#decodeEventV4(record);
|
|
136
|
+
case '5':
|
|
137
|
+
return this.#decodeEventV5(record);
|
|
138
|
+
// Latest
|
|
139
|
+
default:
|
|
140
|
+
return this.#decodeEventV6(record);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
#decodeEventV6 = (record) => {
|
|
144
|
+
const topics = record.event.data[2];
|
|
145
|
+
// Try to match by signature topic (first topic)
|
|
146
|
+
const signatureTopic = topics[0];
|
|
147
|
+
const data = record.event.data[1];
|
|
148
|
+
if (signatureTopic) {
|
|
149
|
+
const event = this.events.find((e) => e.signatureTopic !== undefined && e.signatureTopic !== null && e.signatureTopic === signatureTopic.toHex());
|
|
150
|
+
// Early return if event found by signature topic
|
|
151
|
+
if (event) {
|
|
152
|
+
return event.fromU8a(data);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// If no event returned yet, it might be anonymous
|
|
156
|
+
const amountOfTopics = topics.length;
|
|
157
|
+
const potentialEvents = this.events.filter((e) => {
|
|
158
|
+
// event can't have a signature topic
|
|
159
|
+
if (e.signatureTopic !== null && e.signatureTopic !== undefined) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
// event should have same amount of indexed fields as emitted topics
|
|
163
|
+
const amountIndexed = e.args.filter((a) => a.indexed).length;
|
|
164
|
+
if (amountIndexed !== amountOfTopics) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
// If all conditions met, it's a potential event
|
|
168
|
+
return true;
|
|
169
|
+
});
|
|
170
|
+
if (potentialEvents.length === 1) {
|
|
171
|
+
return potentialEvents[0].fromU8a(data);
|
|
172
|
+
}
|
|
173
|
+
throw new Error('Unable to determine event');
|
|
174
|
+
};
|
|
175
|
+
#decodeEventV5 = (record) => {
|
|
176
|
+
// Find event by first topic, which potentially is the signature_topic
|
|
177
|
+
const signatureTopic = record.topics[0];
|
|
178
|
+
const data = record.event.data[1];
|
|
179
|
+
if (signatureTopic) {
|
|
180
|
+
const event = this.events.find((e) => e.signatureTopic !== undefined && e.signatureTopic !== null && e.signatureTopic === signatureTopic.toHex());
|
|
181
|
+
// Early return if event found by signature topic
|
|
182
|
+
if (event) {
|
|
183
|
+
return event.fromU8a(data);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// If no event returned yet, it might be anonymous
|
|
187
|
+
const amountOfTopics = record.topics.length;
|
|
188
|
+
const potentialEvents = this.events.filter((e) => {
|
|
189
|
+
// event can't have a signature topic
|
|
190
|
+
if (e.signatureTopic !== null && e.signatureTopic !== undefined) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
// event should have same amount of indexed fields as emitted topics
|
|
194
|
+
const amountIndexed = e.args.filter((a) => a.indexed).length;
|
|
195
|
+
if (amountIndexed !== amountOfTopics) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
// If all conditions met, it's a potential event
|
|
199
|
+
return true;
|
|
200
|
+
});
|
|
201
|
+
if (potentialEvents.length === 1) {
|
|
202
|
+
return potentialEvents[0].fromU8a(data);
|
|
203
|
+
}
|
|
204
|
+
throw new Error('Unable to determine event');
|
|
205
|
+
};
|
|
206
|
+
#decodeEventV4 = (record) => {
|
|
207
|
+
const data = record.event.data[1];
|
|
208
|
+
const index = data[0];
|
|
209
|
+
const event = this.events[index];
|
|
210
|
+
if (!event) {
|
|
211
|
+
throw new Error(`Unable to find event with index ${index}`);
|
|
212
|
+
}
|
|
213
|
+
return event.fromU8a(data.subarray(1));
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Warning: Unstable API, bound to change
|
|
217
|
+
*/
|
|
218
|
+
decodeConstructor(data) {
|
|
219
|
+
return this.#decodeMessage('message', this.constructors, data);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Warning: Unstable API, bound to change
|
|
223
|
+
*/
|
|
224
|
+
decodeMessage(data) {
|
|
225
|
+
return this.#decodeMessage('message', this.messages, data);
|
|
226
|
+
}
|
|
227
|
+
findConstructor(constructorOrId) {
|
|
228
|
+
return findMessage(this.constructors, constructorOrId);
|
|
229
|
+
}
|
|
230
|
+
findMessage(messageOrId) {
|
|
231
|
+
return findMessage(this.messages, messageOrId);
|
|
232
|
+
}
|
|
233
|
+
#createArgs = (args, spec) => {
|
|
234
|
+
return args.map(({ label, type }, index) => {
|
|
235
|
+
try {
|
|
236
|
+
if (!isObject(type)) {
|
|
237
|
+
throw new Error('Invalid type definition found');
|
|
238
|
+
}
|
|
239
|
+
const displayName = type.displayName.length
|
|
240
|
+
? type.displayName[type.displayName.length - 1].toString()
|
|
241
|
+
: undefined;
|
|
242
|
+
const camelName = stringCamelCase(label);
|
|
243
|
+
if (displayName && PRIMITIVE_ALWAYS.includes(displayName)) {
|
|
244
|
+
return {
|
|
245
|
+
name: camelName,
|
|
246
|
+
type: {
|
|
247
|
+
info: TypeDefInfo.Plain,
|
|
248
|
+
type: displayName
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const typeDef = this.registry.lookup.getTypeDef(type.type);
|
|
253
|
+
return {
|
|
254
|
+
name: camelName,
|
|
255
|
+
type: displayName && !typeDef.type.startsWith(displayName)
|
|
256
|
+
? { displayName, ...typeDef }
|
|
257
|
+
: typeDef
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
l.error(`Error expanding argument ${index} in ${stringify(spec)}`);
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
#createMessageParams = (args, spec) => {
|
|
267
|
+
return this.#createArgs(args, spec);
|
|
268
|
+
};
|
|
269
|
+
#createEventParams = (args, spec) => {
|
|
270
|
+
const params = this.#createArgs(args, spec);
|
|
271
|
+
return params.map((p, index) => ({ ...p, indexed: args[index].indexed.toPrimitive() }));
|
|
272
|
+
};
|
|
273
|
+
#createEvent = (index) => {
|
|
274
|
+
// TODO TypeScript would narrow this type to the correct version,
|
|
275
|
+
// but version is `Text` so I need to call `toString()` here,
|
|
276
|
+
// which breaks the type inference.
|
|
277
|
+
switch (this.metadata.version.toString()) {
|
|
278
|
+
case '4':
|
|
279
|
+
return this.#createEventV4(this.metadata.spec.events[index], index);
|
|
280
|
+
default:
|
|
281
|
+
return this.#createEventV5(this.metadata.spec.events[index], index);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
#createEventV5 = (spec, index) => {
|
|
285
|
+
const args = this.#createEventParams(spec.args, spec);
|
|
286
|
+
const event = {
|
|
287
|
+
args,
|
|
288
|
+
docs: spec.docs.map((d) => d.toString()),
|
|
289
|
+
fromU8a: (data) => ({
|
|
290
|
+
args: this.#decodeArgs(args, data),
|
|
291
|
+
event
|
|
292
|
+
}),
|
|
293
|
+
identifier: [spec.module_path, spec.label].join('::'),
|
|
294
|
+
index,
|
|
295
|
+
signatureTopic: spec.signature_topic.isSome ? spec.signature_topic.unwrap().toHex() : null
|
|
296
|
+
};
|
|
297
|
+
return event;
|
|
298
|
+
};
|
|
299
|
+
#createEventV4 = (spec, index) => {
|
|
300
|
+
const args = this.#createEventParams(spec.args, spec);
|
|
301
|
+
const event = {
|
|
302
|
+
args,
|
|
303
|
+
docs: spec.docs.map((d) => d.toString()),
|
|
304
|
+
fromU8a: (data) => ({
|
|
305
|
+
args: this.#decodeArgs(args, data),
|
|
306
|
+
event
|
|
307
|
+
}),
|
|
308
|
+
identifier: spec.label.toString(),
|
|
309
|
+
index
|
|
310
|
+
};
|
|
311
|
+
return event;
|
|
312
|
+
};
|
|
313
|
+
#createMessage = (spec, index, add = {}) => {
|
|
314
|
+
const args = this.#createMessageParams(spec.args, spec);
|
|
315
|
+
const identifier = spec.label.toString();
|
|
316
|
+
const message = {
|
|
317
|
+
...add,
|
|
318
|
+
args,
|
|
319
|
+
docs: spec.docs.map((d) => d.toString()),
|
|
320
|
+
fromU8a: (data) => ({
|
|
321
|
+
args: this.#decodeArgs(args, data),
|
|
322
|
+
message
|
|
323
|
+
}),
|
|
324
|
+
identifier,
|
|
325
|
+
index,
|
|
326
|
+
isDefault: spec.default.isTrue,
|
|
327
|
+
method: stringCamelCase(identifier),
|
|
328
|
+
path: identifier.split('::').map((s) => stringCamelCase(s)),
|
|
329
|
+
selector: spec.selector,
|
|
330
|
+
toU8a: (params) => this.#encodeMessageArgs(spec, args, params)
|
|
331
|
+
};
|
|
332
|
+
return message;
|
|
333
|
+
};
|
|
334
|
+
#decodeArgs = (args, data) => {
|
|
335
|
+
// for decoding we expect the input to be just the arg data, no selectors
|
|
336
|
+
// no length added (this allows use with events as well)
|
|
337
|
+
let offset = 0;
|
|
338
|
+
return args.map(({ type: { lookupName, type } }) => {
|
|
339
|
+
const value = this.registry.createType(lookupName || type, data.subarray(offset));
|
|
340
|
+
offset += value.encodedLength;
|
|
341
|
+
return value;
|
|
342
|
+
});
|
|
343
|
+
};
|
|
344
|
+
#decodeMessage = (type, list, data) => {
|
|
345
|
+
const [, trimmed] = compactStripLength(data);
|
|
346
|
+
const selector = trimmed.subarray(0, 4);
|
|
347
|
+
const message = list.find((m) => m.selector.eq(selector));
|
|
348
|
+
if (!message) {
|
|
349
|
+
throw new Error(`Unable to find ${type} with selector ${u8aToHex(selector)}`);
|
|
350
|
+
}
|
|
351
|
+
return message.fromU8a(trimmed.subarray(4));
|
|
352
|
+
};
|
|
353
|
+
#encodeMessageArgs = ({ label, selector }, args, data) => {
|
|
354
|
+
if (data.length !== args.length) {
|
|
355
|
+
throw new Error(`Expected ${args.length} arguments to contract message '${label.toString()}', found ${data.length}`);
|
|
356
|
+
}
|
|
357
|
+
return compactAddLength(u8aConcat(this.registry.createType('ContractSelector', selector).toU8a(), ...args.map(({ type: { lookupName, type } }, index) => this.registry.createType(lookupName || type, data[index]).toU8a())));
|
|
358
|
+
};
|
|
359
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { v0ToV1 } from './toV1.js';
|
|
2
|
+
import { v1ToV2 } from './toV2.js';
|
|
3
|
+
import { v2ToV3 } from './toV3.js';
|
|
4
|
+
import { v3ToV4 } from './toV4.js';
|
|
5
|
+
export const enumVersions = ['V6', 'V5', 'V4', 'V3', 'V2', 'V1'];
|
|
6
|
+
function createConverter(next, step) {
|
|
7
|
+
return (registry, input) => next(registry, step(registry, input));
|
|
8
|
+
}
|
|
9
|
+
export function v6ToLatestCompatible(_registry, v6) {
|
|
10
|
+
return v6;
|
|
11
|
+
}
|
|
12
|
+
export function v5ToLatestCompatible(_registry, v5) {
|
|
13
|
+
return v5;
|
|
14
|
+
}
|
|
15
|
+
export function v4ToLatestCompatible(_registry, v4) {
|
|
16
|
+
return v4;
|
|
17
|
+
}
|
|
18
|
+
export const v3ToLatestCompatible = /*#__PURE__*/ createConverter(v4ToLatestCompatible, v3ToV4);
|
|
19
|
+
export const v2ToLatestCompatible = /*#__PURE__*/ createConverter(v3ToLatestCompatible, v2ToV3);
|
|
20
|
+
export const v1ToLatestCompatible = /*#__PURE__*/ createConverter(v2ToLatestCompatible, v1ToV2);
|
|
21
|
+
export const v0ToLatestCompatible = /*#__PURE__*/ createConverter(v1ToLatestCompatible, v0ToV1);
|
|
22
|
+
export const convertVersions = [
|
|
23
|
+
['V6', v6ToLatestCompatible],
|
|
24
|
+
['V5', v5ToLatestCompatible],
|
|
25
|
+
['V4', v4ToLatestCompatible],
|
|
26
|
+
['V3', v3ToLatestCompatible],
|
|
27
|
+
['V2', v2ToLatestCompatible],
|
|
28
|
+
['V1', v1ToLatestCompatible],
|
|
29
|
+
['V0', v0ToLatestCompatible]
|
|
30
|
+
];
|
package/Abi/toV1.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { convertSiV0toV1 } from '@pezkuwi/types';
|
|
2
|
+
import { objectSpread } from '@pezkuwi/util';
|
|
3
|
+
function v0ToV1Names(all) {
|
|
4
|
+
return all.map((e) => objectSpread({}, e, {
|
|
5
|
+
name: Array.isArray(e.name)
|
|
6
|
+
? e.name
|
|
7
|
+
: [e.name]
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
export function v0ToV1(registry, v0) {
|
|
11
|
+
if (!v0.metadataVersion.length) {
|
|
12
|
+
throw new Error('Invalid format for V0 (detected) contract metadata');
|
|
13
|
+
}
|
|
14
|
+
return registry.createType('ContractMetadataV1', objectSpread({}, v0, {
|
|
15
|
+
spec: objectSpread({}, v0.spec, {
|
|
16
|
+
constructors: v0ToV1Names(v0.spec.constructors),
|
|
17
|
+
messages: v0ToV1Names(v0.spec.messages)
|
|
18
|
+
}),
|
|
19
|
+
types: convertSiV0toV1(registry, v0.types)
|
|
20
|
+
}));
|
|
21
|
+
}
|
package/Abi/toV2.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { objectSpread } from '@pezkuwi/util';
|
|
2
|
+
const ARG_TYPES = {
|
|
3
|
+
ContractConstructorSpec: 'ContractMessageParamSpecV2',
|
|
4
|
+
ContractEventSpec: 'ContractEventParamSpecV2',
|
|
5
|
+
ContractMessageSpec: 'ContractMessageParamSpecV2'
|
|
6
|
+
};
|
|
7
|
+
function v1ToV2Label(entry) {
|
|
8
|
+
return objectSpread({}, entry, {
|
|
9
|
+
label: Array.isArray(entry.name)
|
|
10
|
+
? entry.name.join('::')
|
|
11
|
+
: entry.name
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function v1ToV2Labels(registry, outType, all) {
|
|
15
|
+
return all.map((e) => registry.createType(`${outType}V2`, objectSpread(v1ToV2Label(e), {
|
|
16
|
+
args: e.args.map((a) => registry.createType(ARG_TYPES[outType], v1ToV2Label(a)))
|
|
17
|
+
})));
|
|
18
|
+
}
|
|
19
|
+
export function v1ToV2(registry, v1) {
|
|
20
|
+
return registry.createType('ContractMetadataV2', objectSpread({}, v1, {
|
|
21
|
+
spec: objectSpread({}, v1.spec, {
|
|
22
|
+
constructors: v1ToV2Labels(registry, 'ContractConstructorSpec', v1.spec.constructors),
|
|
23
|
+
events: v1ToV2Labels(registry, 'ContractEventSpec', v1.spec.events),
|
|
24
|
+
messages: v1ToV2Labels(registry, 'ContractMessageSpec', v1.spec.messages)
|
|
25
|
+
})
|
|
26
|
+
}));
|
|
27
|
+
}
|
package/Abi/toV3.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { objectSpread } from '@pezkuwi/util';
|
|
2
|
+
export function v2ToV3(registry, v2) {
|
|
3
|
+
return registry.createType('ContractMetadataV3', objectSpread({}, v2, {
|
|
4
|
+
spec: objectSpread({}, v2.spec, {
|
|
5
|
+
constructors: v2.spec.constructors.map((c) =>
|
|
6
|
+
// V3 introduces the payable flag on constructors, for <V3, it is always true
|
|
7
|
+
registry.createType('ContractConstructorSpecV3', objectSpread({}, c, { payable: true })))
|
|
8
|
+
})
|
|
9
|
+
}));
|
|
10
|
+
}
|
package/Abi/toV4.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { objectSpread } from '@pezkuwi/util';
|
|
2
|
+
export function v3ToV4(registry, v3) {
|
|
3
|
+
return registry.createType('ContractMetadataV4', objectSpread({}, v3, {
|
|
4
|
+
spec: objectSpread({}, v3.spec, {
|
|
5
|
+
constructors: v3.spec.constructors.map((c) => registry.createType('ContractConstructorSpecV4', objectSpread({}, c))),
|
|
6
|
+
messages: v3.spec.messages.map((m) => registry.createType('ContractMessageSpecV3', objectSpread({}, m)))
|
|
7
|
+
}),
|
|
8
|
+
version: registry.createType('Text', '4')
|
|
9
|
+
}));
|
|
10
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
package/augment.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@pezkuwi/api-augment';
|