@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 +6 -0
- package/dist/stellar-base.js +22 -6
- package/dist/stellar-base.min.js +1 -1
- package/lib/invocation.js +22 -6
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
package/lib/invocation.js
CHANGED
|
@@ -8,6 +8,12 @@ exports.walkInvocationTree = walkInvocationTree;
|
|
|
8
8
|
var _asset = require("./asset");
|
|
9
9
|
var _address = require("./address");
|
|
10
10
|
var _scval = require("./scval");
|
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _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; }, _typeof(o); }
|
|
12
|
+
function 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; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
17
|
/**
|
|
12
18
|
* @typedef CreateInvocation
|
|
13
19
|
*
|
|
@@ -21,6 +27,9 @@ var _scval = require("./scval");
|
|
|
21
27
|
* @prop {string} wasm.address contract address of this deployment
|
|
22
28
|
* @prop {string} wasm.salt hex salt that the user consumed when creating
|
|
23
29
|
* this contract (encoded in the resulting address)
|
|
30
|
+
* @prop {any[]} [wasm.constructorArgs] a list of natively-represented values
|
|
31
|
+
* (see {@link scValToNative}) that are passed to the constructor when
|
|
32
|
+
* creating this contract
|
|
24
33
|
*/
|
|
25
34
|
|
|
26
35
|
/**
|
|
@@ -29,8 +38,8 @@ var _scval = require("./scval");
|
|
|
29
38
|
* @prop {string} source the strkey of the contract (C...) being invoked
|
|
30
39
|
* @prop {string} function the name of the function being invoked
|
|
31
40
|
* @prop {any[]} args the natively-represented parameters to the function
|
|
32
|
-
* invocation (see {@link scValToNative}
|
|
33
|
-
* represented a JS types
|
|
41
|
+
* invocation (see {@link scValToNative} for rules on how they're
|
|
42
|
+
* represented a JS types)
|
|
34
43
|
*/
|
|
35
44
|
|
|
36
45
|
/**
|
|
@@ -91,7 +100,7 @@ function buildInvocationTree(root) {
|
|
|
91
100
|
/** @type {InvocationTree} */
|
|
92
101
|
var output = {};
|
|
93
102
|
|
|
94
|
-
/** @type {xdr.CreateContractArgs
|
|
103
|
+
/** @type {xdr.CreateContractArgs|xdr.CreateContractArgsV2|xdr.InvokeContractArgs} */
|
|
95
104
|
var inner = fn.value();
|
|
96
105
|
switch (fn["switch"]().value) {
|
|
97
106
|
// sorobanAuthorizedFunctionTypeContractFn
|
|
@@ -107,8 +116,11 @@ function buildInvocationTree(root) {
|
|
|
107
116
|
break;
|
|
108
117
|
|
|
109
118
|
// sorobanAuthorizedFunctionTypeCreateContractHostFn
|
|
110
|
-
|
|
119
|
+
// sorobanAuthorizedFunctionTypeCreateContractV2HostFn
|
|
120
|
+
case 1: // fallthrough: just no ctor args in V1
|
|
121
|
+
case 2:
|
|
111
122
|
{
|
|
123
|
+
var createV2 = fn["switch"]().value === 2;
|
|
112
124
|
output.type = 'create';
|
|
113
125
|
output.args = {};
|
|
114
126
|
|
|
@@ -132,11 +144,15 @@ function buildInvocationTree(root) {
|
|
|
132
144
|
/** @type {xdr.ContractIdPreimageFromAddress} */
|
|
133
145
|
var details = preimage.fromAddress();
|
|
134
146
|
output.args.type = 'wasm';
|
|
135
|
-
output.args.wasm = {
|
|
147
|
+
output.args.wasm = _objectSpread({
|
|
136
148
|
salt: details.salt().toString('hex'),
|
|
137
149
|
hash: exec.wasmHash().toString('hex'),
|
|
138
150
|
address: _address.Address.fromScAddress(details.address()).toString()
|
|
139
|
-
}
|
|
151
|
+
}, createV2 && {
|
|
152
|
+
constructorArgs: inner.constructorArgs().map(function (arg) {
|
|
153
|
+
return (0, _scval.scValToNative)(arg);
|
|
154
|
+
})
|
|
155
|
+
});
|
|
140
156
|
break;
|
|
141
157
|
}
|
|
142
158
|
|
package/package.json
CHANGED