@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.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.map +1 -1
  4. package/dist/aepp-sdk.browser.js +1 -1
  5. package/dist/aepp-sdk.browser.js.map +1 -1
  6. package/dist/aepp-sdk.js +47 -24
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/AeSdkAepp.d.ts +5 -4
  9. package/es/AeSdkAepp.mjs +13 -17
  10. package/es/AeSdkAepp.mjs.map +1 -1
  11. package/es/account/Generalized.mjs +1 -1
  12. package/es/account/Generalized.mjs.map +1 -1
  13. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  14. package/es/chain.mjs +1 -1
  15. package/es/chain.mjs.map +1 -1
  16. package/es/contract/Contract.mjs +23 -4
  17. package/es/contract/Contract.mjs.map +1 -1
  18. package/es/contract/compiler/Base.d.ts +3 -0
  19. package/es/contract/compiler/Base.mjs.map +1 -1
  20. package/es/index-browser.d.ts +1 -1
  21. package/es/index-browser.mjs +1 -1
  22. package/es/index-browser.mjs.map +1 -1
  23. package/es/utils/errors.mjs +1 -1
  24. package/es/utils/errors.mjs.map +1 -1
  25. package/package.json +3 -3
  26. package/src/AeSdkAepp.ts +16 -14
  27. package/src/account/Generalized.ts +1 -1
  28. package/src/aepp-wallet-communication/rpc/types.ts +1 -0
  29. package/src/chain.ts +1 -1
  30. package/src/contract/Contract.ts +28 -7
  31. package/src/contract/compiler/Base.ts +3 -0
  32. package/src/index-browser.ts +3 -1
  33. package/src/utils/errors.ts +1 -1
  34. package/types-legacy/ts4.2/AeSdkAepp.d.ts +5 -4
  35. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +3 -0
  36. package/types-legacy/ts4.2/index-browser.d.ts +1 -1
  37. package/types-legacy/ts4.5/AeSdkAepp.d.ts +5 -4
  38. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +3 -0
  39. package/types-legacy/ts4.5/index-browser.d.ts +1 -1
@@ -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.bytecode = (await this.$options.onCompiler
138
- .compileBySourceCode(this.$options.sourceCode, this.$options.fileSystem)
139
- ).bytecode;
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, onNode, sourceCode, bytecode, aci, address, fileSystem, ...otherOptions,
516
+ onCompiler,
517
+ onNode,
518
+ sourceCode,
519
+ sourceCodePath,
520
+ bytecode,
521
+ aci,
522
+ address,
523
+ fileSystem,
524
+ ...otherOptions,
504
525
  });
505
526
  }
506
527
 
@@ -13,6 +13,9 @@ export type Aci = Array<{
13
13
  name: string;
14
14
  event?: any;
15
15
  functions: FunctionAci[];
16
+ kind: string; // known values: 'contract_main'
17
+ payable: boolean;
18
+ typedefs: any[];
16
19
  };
17
20
  }>;
18
21
 
@@ -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 { encode, decode, Encoding } from './utils/encoder';
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';
@@ -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 source code is required');
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, select }?: {
44
+ connectToWallet(connection: BrowserConnection, { connectNode, name }?: {
45
45
  connectNode?: boolean;
46
46
  name?: string;
47
- select?: boolean;
48
- }): Promise<WalletInfo>;
47
+ }): Promise<WalletInfo & {
48
+ node?: NodeRpc;
49
+ }>;
49
50
  /**
50
51
  * Disconnect from wallet
51
52
  */
@@ -11,6 +11,9 @@ export type Aci = Array<{
11
11
  name: string;
12
12
  event?: any;
13
13
  functions: FunctionAci[];
14
+ kind: string;
15
+ payable: boolean;
16
+ typedefs: any[];
14
17
  };
15
18
  }>;
16
19
  /**
@@ -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, select }?: {
44
+ connectToWallet(connection: BrowserConnection, { connectNode, name }?: {
45
45
  connectNode?: boolean;
46
46
  name?: string;
47
- select?: boolean;
48
- }): Promise<WalletInfo>;
47
+ }): Promise<WalletInfo & {
48
+ node?: NodeRpc;
49
+ }>;
49
50
  /**
50
51
  * Disconnect from wallet
51
52
  */
@@ -11,6 +11,9 @@ export type Aci = Array<{
11
11
  name: string;
12
12
  event?: any;
13
13
  functions: FunctionAci[];
14
+ kind: string;
15
+ payable: boolean;
16
+ typedefs: any[];
14
17
  };
15
18
  }>;
16
19
  /**
@@ -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';