@stellar/stellar-base 13.0.0 → 13.0.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  ## Unreleased
4
4
 
5
5
 
6
+ ## [`v13.0.1`](https://github.com/stellar/js-stellar-base/compare/v13.0.0...v13.0.1)
7
+
8
+ ### Fixed
9
+ * `buildInvocationTree` will now successfully walk creation invocations with constructor arguments ([#784](https://github.com/stellar/js-stellar-base/pull/784)).
10
+
11
+
6
12
  ## [`v13.0.0`](https://github.com/stellar/js-stellar-base/compare/v12.1.1...v13.0.0)
7
13
 
8
14
  **This release supports Protocol 22.** While the network has not upgraded yet, you can start integrating the new features into your codebase if you want a head start. Keep in mind that while the binary XDR is backwards-compatible, the naming and layout of structures is not. In other words, this build will continue to work on Protocol 21, but you may have to update code that references XDR directly.
@@ -22161,6 +22161,12 @@ function bytesToInt64(bytes) {
22161
22161
  }, 0);
22162
22162
  }
22163
22163
  ;// ./src/invocation.js
22164
+ function invocation_typeof(o) { "@babel/helpers - typeof"; return invocation_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, invocation_typeof(o); }
22165
+ function invocation_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22166
+ function invocation_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? invocation_ownKeys(Object(t), !0).forEach(function (r) { invocation_defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : invocation_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22167
+ function invocation_defineProperty(e, r, t) { return (r = invocation_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
22168
+ function invocation_toPropertyKey(t) { var i = invocation_toPrimitive(t, "string"); return "symbol" == invocation_typeof(i) ? i : i + ""; }
22169
+ function invocation_toPrimitive(t, r) { if ("object" != invocation_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != invocation_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
22164
22170
 
22165
22171
 
22166
22172
 
@@ -22178,6 +22184,9 @@ function bytesToInt64(bytes) {
22178
22184
  * @prop {string} wasm.address contract address of this deployment
22179
22185
  * @prop {string} wasm.salt hex salt that the user consumed when creating
22180
22186
  * this contract (encoded in the resulting address)
22187
+ * @prop {any[]} [wasm.constructorArgs] a list of natively-represented values
22188
+ * (see {@link scValToNative}) that are passed to the constructor when
22189
+ * creating this contract
22181
22190
  */
22182
22191
 
22183
22192
  /**
@@ -22186,8 +22195,8 @@ function bytesToInt64(bytes) {
22186
22195
  * @prop {string} source the strkey of the contract (C...) being invoked
22187
22196
  * @prop {string} function the name of the function being invoked
22188
22197
  * @prop {any[]} args the natively-represented parameters to the function
22189
- * invocation (see {@link scValToNative}) for rules on how they're
22190
- * represented a JS types
22198
+ * invocation (see {@link scValToNative} for rules on how they're
22199
+ * represented a JS types)
22191
22200
  */
22192
22201
 
22193
22202
  /**
@@ -22248,7 +22257,7 @@ function buildInvocationTree(root) {
22248
22257
  /** @type {InvocationTree} */
22249
22258
  var output = {};
22250
22259
 
22251
- /** @type {xdr.CreateContractArgs | xdr.InvokeContractArgs} */
22260
+ /** @type {xdr.CreateContractArgs|xdr.CreateContractArgsV2|xdr.InvokeContractArgs} */
22252
22261
  var inner = fn.value();
22253
22262
  switch (fn["switch"]().value) {
22254
22263
  // sorobanAuthorizedFunctionTypeContractFn
@@ -22264,8 +22273,11 @@ function buildInvocationTree(root) {
22264
22273
  break;
22265
22274
 
22266
22275
  // sorobanAuthorizedFunctionTypeCreateContractHostFn
22267
- case 1:
22276
+ // sorobanAuthorizedFunctionTypeCreateContractV2HostFn
22277
+ case 1: // fallthrough: just no ctor args in V1
22278
+ case 2:
22268
22279
  {
22280
+ var createV2 = fn["switch"]().value === 2;
22269
22281
  output.type = 'create';
22270
22282
  output.args = {};
22271
22283
 
@@ -22289,11 +22301,15 @@ function buildInvocationTree(root) {
22289
22301
  /** @type {xdr.ContractIdPreimageFromAddress} */
22290
22302
  var details = preimage.fromAddress();
22291
22303
  output.args.type = 'wasm';
22292
- output.args.wasm = {
22304
+ output.args.wasm = invocation_objectSpread({
22293
22305
  salt: details.salt().toString('hex'),
22294
22306
  hash: exec.wasmHash().toString('hex'),
22295
22307
  address: Address.fromScAddress(details.address()).toString()
22296
- };
22308
+ }, createV2 && {
22309
+ constructorArgs: inner.constructorArgs().map(function (arg) {
22310
+ return scValToNative(arg);
22311
+ })
22312
+ });
22297
22313
  break;
22298
22314
  }
22299
22315