@agoric/vats 0.15.2-dev-d3223ae.0 → 0.15.2-dev-644c210.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/package.json +16 -16
- package/tools/fake-bridge.d.ts +5 -0
- package/tools/fake-bridge.d.ts.map +1 -1
- package/tools/fake-bridge.js +63 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vats",
|
|
3
|
-
"version": "0.15.2-dev-
|
|
3
|
+
"version": "0.15.2-dev-644c210.0+644c210",
|
|
4
4
|
"description": "Agoric's Vat library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
26
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
27
|
-
"@agoric/governance": "0.10.4-dev-
|
|
28
|
-
"@agoric/internal": "0.3.3-dev-
|
|
29
|
-
"@agoric/network": "0.1.1-dev-
|
|
30
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
31
|
-
"@agoric/store": "0.9.3-dev-
|
|
32
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
33
|
-
"@agoric/time": "0.3.3-dev-
|
|
34
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
35
|
-
"@agoric/vow": "0.1.1-dev-
|
|
36
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
37
|
-
"@agoric/zone": "0.2.3-dev-
|
|
25
|
+
"@agoric/cosmic-proto": "0.4.1-dev-644c210.0+644c210",
|
|
26
|
+
"@agoric/ertp": "0.16.3-dev-644c210.0+644c210",
|
|
27
|
+
"@agoric/governance": "0.10.4-dev-644c210.0+644c210",
|
|
28
|
+
"@agoric/internal": "0.3.3-dev-644c210.0+644c210",
|
|
29
|
+
"@agoric/network": "0.1.1-dev-644c210.0+644c210",
|
|
30
|
+
"@agoric/notifier": "0.6.3-dev-644c210.0+644c210",
|
|
31
|
+
"@agoric/store": "0.9.3-dev-644c210.0+644c210",
|
|
32
|
+
"@agoric/swingset-vat": "0.32.3-dev-644c210.0+644c210",
|
|
33
|
+
"@agoric/time": "0.3.3-dev-644c210.0+644c210",
|
|
34
|
+
"@agoric/vat-data": "0.5.3-dev-644c210.0+644c210",
|
|
35
|
+
"@agoric/vow": "0.1.1-dev-644c210.0+644c210",
|
|
36
|
+
"@agoric/zoe": "0.26.3-dev-644c210.0+644c210",
|
|
37
|
+
"@agoric/zone": "0.2.3-dev-644c210.0+644c210",
|
|
38
38
|
"@endo/errors": "^1.2.4",
|
|
39
39
|
"@endo/far": "^1.1.4",
|
|
40
40
|
"@endo/import-bundle": "^1.2.1",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"jessie.js": "^0.3.4"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
49
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-644c210.0+644c210",
|
|
50
50
|
"@endo/bundle-source": "^3.3.0",
|
|
51
51
|
"@endo/init": "^1.1.3",
|
|
52
52
|
"ava": "^5.3.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"typeCoverage": {
|
|
79
79
|
"atLeast": 91.52
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "644c210038bc4beefe87691373f162ffa33a272b"
|
|
82
82
|
}
|
package/tools/fake-bridge.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export function makeFakeBankBridge(zone: import("@agoric/zone").Zone, opts?: {
|
|
|
5
5
|
}): ScopedBridgeManager<"bank">;
|
|
6
6
|
export function makeFakeIbcBridge(zone: import("@agoric/zone").Zone, onToBridge: (obj: any) => void): ScopedBridgeManager<"dibc">;
|
|
7
7
|
export const LOCALCHAIN_DEFAULT_ADDRESS: "agoric1fakeLCAAddress";
|
|
8
|
+
export namespace SIMULATED_ERRORS {
|
|
9
|
+
let TIMEOUT: bigint;
|
|
10
|
+
let BAD_REQUEST: bigint;
|
|
11
|
+
}
|
|
12
|
+
export function fakeLocalChainBridgeTxMsgHandler(message: object, sequence: number): unknown;
|
|
8
13
|
export function makeFakeLocalchainBridge(zone: import("@agoric/zone").Zone, onToBridge?: ((obj: any) => void) | undefined): ScopedBridgeManager<"vlocalchain">;
|
|
9
14
|
export function makeFakeTransferBridge(zone: import("@agoric/zone").Zone, onToBridge?: ((obj: any) => void) | undefined): ScopedBridgeManager<"vtransfer">;
|
|
10
15
|
export type Balances = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-bridge.d.ts","sourceRoot":"","sources":["fake-bridge.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fake-bridge.d.ts","sourceRoot":"","sources":["fake-bridge.js"],"names":[],"mappings":"AAkBA,6EAA6E;AAE7E,sCAAuC;AAchC,yCANI,OAAO,cAAc,EAAE,IAAI,SAEnC;IAAuB,QAAQ,EAAvB,QAAQ;CAChB,GAAU,oBAAoB,MAAM,CAAC,CA0FvC;AAOM,wCAJI,OAAO,cAAc,EAAE,IAAI,cAC3B,CAAC,GAAG,KAAA,KAAK,IAAI,GACX,oBAAoB,MAAM,CAAC,CA8BvC;AAED,iEAAkE;;;;;AAwB3D,0DALI,MAAM,YACN,MAAM,GACJ,OAAO,CAsCnB;AAOM,+CAJI,OAAO,cAAc,EAAE,IAAI,8BAClB,IAAI,gBACX,oBAAoB,aAAa,CAAC,CA2C9C;AAOM,6CAJI,OAAO,cAAc,EAAE,IAAI,8BAClB,IAAI,gBACX,oBAAoB,WAAW,CAAC,CAuC5C;uBAnSa;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;CAAE;yCAPX,iBAAiB"}
|
package/tools/fake-bridge.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Nat } from '@endo/nat';
|
|
|
8
8
|
/**
|
|
9
9
|
* @import {JsonSafe} from '@agoric/cosmic-proto';
|
|
10
10
|
* @import {MsgDelegateResponse, MsgUndelegateResponse} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js';
|
|
11
|
+
* @import {MsgSendResponse} from '@agoric/cosmic-proto/cosmos/bank/v1beta1/tx.js';
|
|
11
12
|
* @import {BridgeHandler, ScopedBridgeManager} from '../src/types.js';
|
|
12
13
|
* @import {Remote} from '@agoric/vow';
|
|
13
14
|
*/
|
|
@@ -157,6 +158,65 @@ export const makeFakeIbcBridge = (zone, onToBridge) => {
|
|
|
157
158
|
|
|
158
159
|
export const LOCALCHAIN_DEFAULT_ADDRESS = 'agoric1fakeLCAAddress';
|
|
159
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Constants that can be used to force an error state in a bridge transaction.
|
|
163
|
+
* Typically used for the LocalChainBridge which currently accepts all messages
|
|
164
|
+
* unless specified otherwise. Less useful for the DibcBridge which rejects all
|
|
165
|
+
* messages unless specified otherwise.
|
|
166
|
+
*/
|
|
167
|
+
export const SIMULATED_ERRORS = {
|
|
168
|
+
TIMEOUT: 504n,
|
|
169
|
+
BAD_REQUEST: 400n,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Used to mock responses from Cosmos Golang back to SwingSet for for
|
|
174
|
+
* E(lca).executeTx().
|
|
175
|
+
*
|
|
176
|
+
* Returns an empty object per message unless specified.
|
|
177
|
+
*
|
|
178
|
+
* @param {object} message
|
|
179
|
+
* @param {number} sequence
|
|
180
|
+
* @returns {unknown}
|
|
181
|
+
* @throws {Error} to simulate failures in certain cases
|
|
182
|
+
*/
|
|
183
|
+
export const fakeLocalChainBridgeTxMsgHandler = (message, sequence) => {
|
|
184
|
+
switch (message['@type']) {
|
|
185
|
+
// TODO #9402 reference bank to ensure caller has tokens they are transferring
|
|
186
|
+
case '/ibc.applications.transfer.v1.MsgTransfer': {
|
|
187
|
+
if (message.token.amount === String(SIMULATED_ERRORS.TIMEOUT)) {
|
|
188
|
+
throw Error('simulated unexpected MsgTransfer packet timeout');
|
|
189
|
+
}
|
|
190
|
+
// like `JsonSafe<MsgTransferResponse>`, but bigints are converted to numbers
|
|
191
|
+
// FIXME should vlocalchain return a string instead of number for bigint?
|
|
192
|
+
return {
|
|
193
|
+
sequence,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
case '/cosmos.bank.v1beta1.MsgSend': {
|
|
197
|
+
if (message.amount[0].amount === String(SIMULATED_ERRORS.BAD_REQUEST)) {
|
|
198
|
+
throw Error('simulated error');
|
|
199
|
+
}
|
|
200
|
+
return /** @type {JsonSafe<MsgSendResponse>} */ ({});
|
|
201
|
+
}
|
|
202
|
+
case '/cosmos.staking.v1beta1.MsgDelegate': {
|
|
203
|
+
if (message.amount.amount === String(SIMULATED_ERRORS.TIMEOUT)) {
|
|
204
|
+
throw Error('simulated packet timeout');
|
|
205
|
+
}
|
|
206
|
+
return /** @type {JsonSafe<MsgDelegateResponse>} */ ({});
|
|
207
|
+
}
|
|
208
|
+
case '/cosmos.staking.v1beta1.MsgUndelegate': {
|
|
209
|
+
return /** @type {JsonSafe<MsgUndelegateResponse>} */ ({
|
|
210
|
+
// 5 seconds from unix epoch
|
|
211
|
+
completionTime: { seconds: 5n, nanos: 0 },
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
// returns one empty object per message unless specified
|
|
215
|
+
default:
|
|
216
|
+
return {};
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
160
220
|
/**
|
|
161
221
|
* @param {import('@agoric/zone').Zone} zone
|
|
162
222
|
* @param {(obj) => void} [onToBridge]
|
|
@@ -181,38 +241,9 @@ export const makeFakeLocalchainBridge = (zone, onToBridge = () => {}) => {
|
|
|
181
241
|
}
|
|
182
242
|
case 'VLOCALCHAIN_EXECUTE_TX': {
|
|
183
243
|
lcaExecuteTxSequence += 1;
|
|
184
|
-
return obj.messages.map(message =>
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
case '/ibc.applications.transfer.v1.MsgTransfer': {
|
|
188
|
-
if (message.token.amount === '504') {
|
|
189
|
-
throw Error(
|
|
190
|
-
'simulated unexpected MsgTransfer packet timeout',
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
// like `JsonSafe<MsgTransferResponse>`, but bigints are converted to numbers
|
|
194
|
-
// XXX should vlocalchain return a string instead of number for bigint?
|
|
195
|
-
return {
|
|
196
|
-
sequence: lcaExecuteTxSequence,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
case '/cosmos.staking.v1beta1.MsgDelegate': {
|
|
200
|
-
if (message.amount.amount === '504') {
|
|
201
|
-
throw Error('simulated packet timeout');
|
|
202
|
-
}
|
|
203
|
-
return /** @type {JsonSafe<MsgDelegateResponse>} */ ({});
|
|
204
|
-
}
|
|
205
|
-
case '/cosmos.staking.v1beta1.MsgUndelegate': {
|
|
206
|
-
return /** @type {JsonSafe<MsgUndelegateResponse>} */ ({
|
|
207
|
-
// 5 seconds from unix epoch
|
|
208
|
-
completionTime: { seconds: 5n, nanos: 0 },
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
// returns one empty object per message unless specified
|
|
212
|
-
default:
|
|
213
|
-
return {};
|
|
214
|
-
}
|
|
215
|
-
});
|
|
244
|
+
return obj.messages.map(message =>
|
|
245
|
+
fakeLocalChainBridgeTxMsgHandler(message, lcaExecuteTxSequence),
|
|
246
|
+
);
|
|
216
247
|
}
|
|
217
248
|
default:
|
|
218
249
|
Fail`unknown type ${type}`;
|