@aeternity/aepp-sdk 13.0.0-beta.0 → 13.0.0
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/README.md +1 -1
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +47 -24
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdkAepp.d.ts +5 -4
- package/es/AeSdkAepp.mjs +13 -17
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/account/Generalized.mjs +1 -1
- package/es/account/Generalized.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/chain.mjs +1 -1
- package/es/chain.mjs.map +1 -1
- package/es/contract/Contract.mjs +23 -4
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +3 -0
- package/es/contract/compiler/Base.mjs.map +1 -1
- package/es/index-browser.d.ts +1 -1
- package/es/index-browser.mjs +1 -1
- package/es/index-browser.mjs.map +1 -1
- package/es/utils/errors.mjs +1 -1
- package/es/utils/errors.mjs.map +1 -1
- package/package.json +3 -3
- package/src/AeSdkAepp.ts +16 -14
- package/src/account/Generalized.ts +1 -1
- package/src/aepp-wallet-communication/rpc/types.ts +1 -0
- package/src/chain.ts +1 -1
- package/src/contract/Contract.ts +28 -7
- package/src/contract/compiler/Base.ts +3 -0
- package/src/index-browser.ts +3 -1
- package/src/utils/errors.ts +1 -1
- package/types-legacy/ts4.2/AeSdkAepp.d.ts +5 -4
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +3 -0
- package/types-legacy/ts4.2/index-browser.d.ts +1 -1
- package/types-legacy/ts4.5/AeSdkAepp.d.ts +5 -4
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +3 -0
- package/types-legacy/ts4.5/index-browser.d.ts +1 -1
package/src/contract/Contract.ts
CHANGED
|
@@ -132,11 +132,19 @@ class Contract<M extends ContractMethodsBase> {
|
|
|
132
132
|
*/
|
|
133
133
|
async $compile(): Promise<Encoded.ContractBytearray> {
|
|
134
134
|
if (this.$options.bytecode != null) return this.$options.bytecode;
|
|
135
|
-
if (this.$options.sourceCode == null) throw new IllegalArgumentError('Can\'t compile without source code');
|
|
136
135
|
if (this.$options.onCompiler == null) throw new IllegalArgumentError('Can\'t compile without compiler');
|
|
137
|
-
this.$options.
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
if (this.$options.sourceCode != null) {
|
|
137
|
+
const { bytecode } = await this.$options.onCompiler
|
|
138
|
+
.compileBySourceCode(this.$options.sourceCode, this.$options.fileSystem);
|
|
139
|
+
this.$options.bytecode = bytecode;
|
|
140
|
+
}
|
|
141
|
+
if (this.$options.sourceCodePath != null) {
|
|
142
|
+
const { bytecode } = await this.$options.onCompiler.compile(this.$options.sourceCodePath);
|
|
143
|
+
this.$options.bytecode = bytecode;
|
|
144
|
+
}
|
|
145
|
+
if (this.$options.bytecode == null) {
|
|
146
|
+
throw new IllegalArgumentError('Can\'t compile without sourceCode and sourceCodePath');
|
|
147
|
+
}
|
|
140
148
|
return this.$options.bytecode;
|
|
141
149
|
}
|
|
142
150
|
|
|
@@ -478,7 +486,7 @@ class Contract<M extends ContractMethodsBase> {
|
|
|
478
486
|
) as Encoded.ContractAddress;
|
|
479
487
|
}
|
|
480
488
|
|
|
481
|
-
if (address == null && sourceCode == null && bytecode == null) {
|
|
489
|
+
if (address == null && sourceCode == null && sourceCodePath == null && bytecode == null) {
|
|
482
490
|
throw new MissingContractAddressError('Can\'t create instance by ACI without address');
|
|
483
491
|
}
|
|
484
492
|
|
|
@@ -495,12 +503,25 @@ class Contract<M extends ContractMethodsBase> {
|
|
|
495
503
|
else if (sourceCode != null) {
|
|
496
504
|
if (onCompiler == null) throw new IllegalArgumentError('Can\'t validate bytecode without compiler');
|
|
497
505
|
isValid = await onCompiler.validateBySourceCode(onChanBytecode, sourceCode, fileSystem);
|
|
506
|
+
} else if (sourceCodePath != null) {
|
|
507
|
+
if (onCompiler == null) throw new IllegalArgumentError('Can\'t validate bytecode without compiler');
|
|
508
|
+
isValid = await onCompiler.validate(onChanBytecode, sourceCodePath);
|
|
509
|
+
}
|
|
510
|
+
if (!isValid) {
|
|
511
|
+
throw new BytecodeMismatchError((sourceCode ?? sourceCodePath) != null ? 'source code' : 'bytecode');
|
|
498
512
|
}
|
|
499
|
-
if (!isValid) throw new BytecodeMismatchError(sourceCode != null ? 'source code' : 'bytecode');
|
|
500
513
|
}
|
|
501
514
|
|
|
502
515
|
return new ContractWithMethods<M>({
|
|
503
|
-
onCompiler,
|
|
516
|
+
onCompiler,
|
|
517
|
+
onNode,
|
|
518
|
+
sourceCode,
|
|
519
|
+
sourceCodePath,
|
|
520
|
+
bytecode,
|
|
521
|
+
aci,
|
|
522
|
+
address,
|
|
523
|
+
fileSystem,
|
|
524
|
+
...otherOptions,
|
|
504
525
|
});
|
|
505
526
|
}
|
|
506
527
|
|
package/src/index-browser.ts
CHANGED
|
@@ -18,7 +18,9 @@ export {
|
|
|
18
18
|
export { default as getTransactionSignerAddress } from './tx/transaction-signer';
|
|
19
19
|
export * from './utils/amount-formatter';
|
|
20
20
|
export * from './utils/hd-wallet';
|
|
21
|
-
export {
|
|
21
|
+
export {
|
|
22
|
+
encode, decode, Encoding, Encoded,
|
|
23
|
+
} from './utils/encoder';
|
|
22
24
|
export * from './aens';
|
|
23
25
|
export { default as Contract } from './contract/Contract';
|
|
24
26
|
export type { ContractMethodsBase } from './contract/Contract';
|
package/src/utils/errors.ts
CHANGED
|
@@ -488,7 +488,7 @@ export class MissingContractAddressError extends ContractError {
|
|
|
488
488
|
*/
|
|
489
489
|
export class MissingContractDefError extends ContractError {
|
|
490
490
|
constructor() {
|
|
491
|
-
super('Either ACI or
|
|
491
|
+
super('Either ACI or sourceCode or sourceCodePath is required');
|
|
492
492
|
this.name = 'MissingContractDefError';
|
|
493
493
|
}
|
|
494
494
|
}
|
|
@@ -2,7 +2,7 @@ import AeSdkBase from './AeSdkBase';
|
|
|
2
2
|
import { OnAccount } from './AeSdkMethods';
|
|
3
3
|
import AccountBase from './account/Base';
|
|
4
4
|
import { Encoded } from './utils/encoder';
|
|
5
|
-
import { Accounts, WalletInfo, Network, WalletApi, AeppApi } from './aepp-wallet-communication/rpc/types';
|
|
5
|
+
import { Accounts, WalletInfo, Network, WalletApi, AeppApi, Node as NodeRpc } from './aepp-wallet-communication/rpc/types';
|
|
6
6
|
import RpcClient from './aepp-wallet-communication/rpc/RpcClient';
|
|
7
7
|
import { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema';
|
|
8
8
|
import BrowserConnection from './aepp-wallet-communication/connection/Browser';
|
|
@@ -41,11 +41,12 @@ export default class AeSdkAepp extends AeSdkBase {
|
|
|
41
41
|
* @param options.name - Node name
|
|
42
42
|
* @param options.select - Select this node as current
|
|
43
43
|
*/
|
|
44
|
-
connectToWallet(connection: BrowserConnection, { connectNode, name
|
|
44
|
+
connectToWallet(connection: BrowserConnection, { connectNode, name }?: {
|
|
45
45
|
connectNode?: boolean;
|
|
46
46
|
name?: string;
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
}): Promise<WalletInfo & {
|
|
48
|
+
node?: NodeRpc;
|
|
49
|
+
}>;
|
|
49
50
|
/**
|
|
50
51
|
* Disconnect from wallet
|
|
51
52
|
*/
|
|
@@ -10,7 +10,7 @@ export { getExecutionCost, getExecutionCostBySignedTx, getExecutionCostUsingNode
|
|
|
10
10
|
export { default as getTransactionSignerAddress } from './tx/transaction-signer';
|
|
11
11
|
export * from './utils/amount-formatter';
|
|
12
12
|
export * from './utils/hd-wallet';
|
|
13
|
-
export { encode, decode, Encoding } from './utils/encoder';
|
|
13
|
+
export { encode, decode, Encoding, Encoded, } from './utils/encoder';
|
|
14
14
|
export * from './aens';
|
|
15
15
|
export { default as Contract } from './contract/Contract';
|
|
16
16
|
export type { ContractMethodsBase } from './contract/Contract';
|
|
@@ -2,7 +2,7 @@ import AeSdkBase from './AeSdkBase';
|
|
|
2
2
|
import { OnAccount } from './AeSdkMethods';
|
|
3
3
|
import AccountBase from './account/Base';
|
|
4
4
|
import { Encoded } from './utils/encoder';
|
|
5
|
-
import { Accounts, WalletInfo, Network, WalletApi, AeppApi } from './aepp-wallet-communication/rpc/types';
|
|
5
|
+
import { Accounts, WalletInfo, Network, WalletApi, AeppApi, Node as NodeRpc } from './aepp-wallet-communication/rpc/types';
|
|
6
6
|
import RpcClient from './aepp-wallet-communication/rpc/RpcClient';
|
|
7
7
|
import { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema';
|
|
8
8
|
import BrowserConnection from './aepp-wallet-communication/connection/Browser';
|
|
@@ -41,11 +41,12 @@ export default class AeSdkAepp extends AeSdkBase {
|
|
|
41
41
|
* @param options.name - Node name
|
|
42
42
|
* @param options.select - Select this node as current
|
|
43
43
|
*/
|
|
44
|
-
connectToWallet(connection: BrowserConnection, { connectNode, name
|
|
44
|
+
connectToWallet(connection: BrowserConnection, { connectNode, name }?: {
|
|
45
45
|
connectNode?: boolean;
|
|
46
46
|
name?: string;
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
}): Promise<WalletInfo & {
|
|
48
|
+
node?: NodeRpc;
|
|
49
|
+
}>;
|
|
49
50
|
/**
|
|
50
51
|
* Disconnect from wallet
|
|
51
52
|
*/
|
|
@@ -10,7 +10,7 @@ export { getExecutionCost, getExecutionCostBySignedTx, getExecutionCostUsingNode
|
|
|
10
10
|
export { default as getTransactionSignerAddress } from './tx/transaction-signer';
|
|
11
11
|
export * from './utils/amount-formatter';
|
|
12
12
|
export * from './utils/hd-wallet';
|
|
13
|
-
export { encode, decode, Encoding } from './utils/encoder';
|
|
13
|
+
export { encode, decode, Encoding, Encoded, } from './utils/encoder';
|
|
14
14
|
export * from './aens';
|
|
15
15
|
export { default as Contract } from './contract/Contract';
|
|
16
16
|
export type { ContractMethodsBase } from './contract/Contract';
|