ecash-agora 2.1.0 → 2.2.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 +5 -1
- package/dist/actions.d.ts +25 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +73 -0
- package/dist/actions.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/tests/actions.test.ts +281 -0
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ await chronik.broadcastTx(acceptTx.ser());
|
|
|
125
125
|
```
|
|
126
126
|
mkdir build/
|
|
127
127
|
cd build/
|
|
128
|
-
cmake -GNinja .. -
|
|
128
|
+
cmake -GNinja .. -DBUILD_CHRONIK=ON -DBUILD_CHRONIK_PLUGINS=ON
|
|
129
129
|
ninja
|
|
130
130
|
```
|
|
131
131
|
|
|
@@ -199,3 +199,7 @@ Running from `bitcoin-abc/modules/ecash-agora` if your build dir is `bitcoin-abc
|
|
|
199
199
|
### 2.1.0
|
|
200
200
|
|
|
201
201
|
- Add support for "UNKNOWN" token protocol type in chronik-client [D18155](https://reviews.bitcoinabc.org/D18155)
|
|
202
|
+
|
|
203
|
+
### 2.2.0
|
|
204
|
+
|
|
205
|
+
- Add `src/actions.ts` to support preparing payment Actions for `ecash-wallet`, and add `actions.test.ts` to show implementation [D18673](https://reviews.bitcoinabc.org/D18673)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { payment, TokenType } from 'ecash-lib';
|
|
2
|
+
import { AgoraOfferVariant } from './agora.js';
|
|
3
|
+
/**
|
|
4
|
+
* Action to request a payment.Action that will
|
|
5
|
+
* create an Agora listing
|
|
6
|
+
*/
|
|
7
|
+
export interface ListAction {
|
|
8
|
+
/** The type of agora action, used to distinguish between different spec-enabled actions */
|
|
9
|
+
type: 'LIST';
|
|
10
|
+
/**
|
|
11
|
+
* While tokenType can be inferred from an agora partial,
|
|
12
|
+
* it cannot be inferred from an agora ONESHOT,
|
|
13
|
+
* so we need to specify it here
|
|
14
|
+
*/
|
|
15
|
+
tokenType: TokenType;
|
|
16
|
+
/** The variant of the agora action to be listed */
|
|
17
|
+
variant: AgoraOfferVariant;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Supported agora actions that can be converted to a payment.Action
|
|
21
|
+
* for build and broadcast by ecash-wallet
|
|
22
|
+
*/
|
|
23
|
+
export type AgoraAction = ListAction;
|
|
24
|
+
export declare const getAgoraPaymentAction: (action: ListAction, dustSats?: bigint) => payment.Action;
|
|
25
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,OAAO,EACP,SAAS,EAGZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,UAAU;IACvB,2FAA2F;IAC3F,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,SAAS,EAAE,SAAS,CAAC;IACrB,mDAAmD;IACnD,OAAO,EAAE,iBAAiB,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC;AAErC,eAAO,MAAM,qBAAqB,WACtB,UAAU,wBAEnB,QAAQ,MAwEV,CAAC"}
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2025 The Bitcoin developers
|
|
3
|
+
// Distributed under the MIT software license, see the accompanying
|
|
4
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getAgoraPaymentAction = void 0;
|
|
7
|
+
const ecash_lib_1 = require("ecash-lib");
|
|
8
|
+
const getAgoraPaymentAction = (action, dustSats = ecash_lib_1.DEFAULT_DUST_SATS) => {
|
|
9
|
+
const { type, tokenType, variant } = action;
|
|
10
|
+
switch (tokenType.protocol) {
|
|
11
|
+
case 'SLP': {
|
|
12
|
+
throw new Error('SLP is not currently supported.');
|
|
13
|
+
}
|
|
14
|
+
case 'ALP': {
|
|
15
|
+
switch (type) {
|
|
16
|
+
case 'LIST': {
|
|
17
|
+
/**
|
|
18
|
+
* Handle an ALP list action
|
|
19
|
+
*
|
|
20
|
+
* An ALP list action requires a data action and a send action
|
|
21
|
+
* Unlike SLP list actions, it can be completed in a single tx
|
|
22
|
+
*/
|
|
23
|
+
if (variant.type === 'ONESHOT') {
|
|
24
|
+
throw new Error('ALP ONESHOT listings are not currently supported');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* We only support AgoraPartial listings for ALP
|
|
28
|
+
*
|
|
29
|
+
* An AgoraPartial listing requires
|
|
30
|
+
* - A data tokenAction of agoraPartial.adPushdata() at the beginning of the EMPP OP_RETURN
|
|
31
|
+
* - A SEND tokenAction to send the listed tokens to the p2sh output
|
|
32
|
+
* - A blank OP_RETURN template output at index 0
|
|
33
|
+
* - A p2sh output to hold the listed tokens
|
|
34
|
+
*
|
|
35
|
+
* ecash-wallet can handle token change and XEC change, so we do not need to build it here
|
|
36
|
+
*/
|
|
37
|
+
return {
|
|
38
|
+
outputs: [
|
|
39
|
+
{ sats: 0n },
|
|
40
|
+
{
|
|
41
|
+
sats: dustSats,
|
|
42
|
+
script: ecash_lib_1.Script.p2sh((0, ecash_lib_1.shaRmd160)(variant.params.script().bytecode)),
|
|
43
|
+
tokenId: variant.params.tokenId,
|
|
44
|
+
atoms: variant.params.offeredAtoms(),
|
|
45
|
+
isMintBaton: false,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
tokenActions: [
|
|
49
|
+
{
|
|
50
|
+
type: 'DATA',
|
|
51
|
+
data: variant.params.adPushdata(),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: 'SEND',
|
|
55
|
+
tokenId: variant.params.tokenId,
|
|
56
|
+
tokenType: tokenType,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
default: {
|
|
62
|
+
// Cannot get here with valid typed input
|
|
63
|
+
throw new Error(`Unsupported agora action: ${type}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
default: {
|
|
68
|
+
throw new Error(`Unsupported token protocol: ${tokenType.protocol}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.getAgoraPaymentAction = getAgoraPaymentAction;
|
|
73
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;AAEtE,yCAMmB;AA0BZ,MAAM,qBAAqB,GAAG,CACjC,MAAkB,EAClB,QAAQ,GAAG,6BAAiB,EACd,EAAE;IAChB,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAE5C,QAAQ,SAAS,CAAC,QAAQ,EAAE,CAAC;QACzB,KAAK,KAAK,CAAC,CAAC,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACvD,CAAC;QACD,KAAK,KAAK,CAAC,CAAC,CAAC;YACT,QAAQ,IAAI,EAAE,CAAC;gBACX,KAAK,MAAM,CAAC,CAAC,CAAC;oBACV;;;;;uBAKG;oBACH,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;wBAC7B,MAAM,IAAI,KAAK,CACX,kDAAkD,CACrD,CAAC;oBACN,CAAC;oBAED;;;;;;;;;;uBAUG;oBAEH,OAAO;wBACH,OAAO,EAAE;4BACL,EAAE,IAAI,EAAE,EAAE,EAAE;4BACZ;gCACI,IAAI,EAAE,QAAQ;gCACd,MAAM,EAAE,kBAAM,CAAC,IAAI,CACf,IAAA,qBAAS,EAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,CAC9C;gCACD,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO;gCAC/B,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE;gCACpC,WAAW,EAAE,KAAK;6BACrB;yBACJ;wBACD,YAAY,EAAE;4BACV;gCACI,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE;6BACpC;4BACD;gCACI,IAAI,EAAE,MAAM;gCACZ,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO;gCAC/B,SAAS,EAAE,SAAS;6BACvB;yBACJ;qBACJ,CAAC;gBACN,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACN,yCAAyC;oBACzC,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;gBACzD,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACN,MAAM,IAAI,KAAK,CACX,+BAA+B,SAAS,CAAC,QAAQ,EAAE,CACtD,CAAC;QACN,CAAC;IACL,CAAC;AACL,CAAC,CAAC;AA3EW,QAAA,qBAAqB,yBA2EhC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
__exportStar(require("./ad.js"), exports);
|
|
21
21
|
__exportStar(require("./agora.js"), exports);
|
|
22
|
+
__exportStar(require("./actions.js"), exports);
|
|
22
23
|
__exportStar(require("./consts.js"), exports);
|
|
23
24
|
__exportStar(require("./inputs.js"), exports);
|
|
24
25
|
__exportStar(require("./oneshot.js"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;;;;;;;;;;;;;;AAEtE,0CAAwB;AACxB,6CAA2B;AAC3B,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;;;;;;;;;;;;;;AAEtE,0CAAwB;AACxB,6CAA2B;AAC3B,+CAA6B;AAC7B,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecash-agora",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Library for interacting with the eCash Agora protocol",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@types/node": "^20.12.7",
|
|
35
35
|
"chai": "^4.4.1",
|
|
36
36
|
"chai-as-promised": "^7.1.1",
|
|
37
|
+
"ecash-wallet": "^2.0.1",
|
|
37
38
|
"mocha": "^10.4.0",
|
|
38
39
|
"mocha-junit-reporter": "^2.2.1",
|
|
39
40
|
"nyc": "^15.1.0",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"typescript": "^5.4.3"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"chronik-client": "^3.
|
|
47
|
-
"ecash-lib": "^3.
|
|
47
|
+
"chronik-client": "^3.4.0",
|
|
48
|
+
"ecash-lib": "^4.3.3"
|
|
48
49
|
}
|
|
49
50
|
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
// Copyright (c) 2025 The Bitcoin developers
|
|
2
|
+
// Distributed under the MIT software license, see the accompanying
|
|
3
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* actions.test.ts
|
|
7
|
+
*
|
|
8
|
+
* Show src/actions.ts can be used to create actions
|
|
9
|
+
* that lead to valid agora txs broadcast by ecash-wallet
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { expect, use } from 'chai';
|
|
13
|
+
import chaiAsPromised from 'chai-as-promised';
|
|
14
|
+
import { ChronikClient } from 'chronik-client';
|
|
15
|
+
import {
|
|
16
|
+
toHex,
|
|
17
|
+
fromHex,
|
|
18
|
+
payment,
|
|
19
|
+
SLP_TOKEN_TYPE_FUNGIBLE,
|
|
20
|
+
ALP_TOKEN_TYPE_STANDARD,
|
|
21
|
+
SLP_TOKEN_TYPE_MINT_VAULT,
|
|
22
|
+
SLP_TOKEN_TYPE_NFT1_GROUP,
|
|
23
|
+
SLP_TOKEN_TYPE_NFT1_CHILD,
|
|
24
|
+
slpSend,
|
|
25
|
+
Address,
|
|
26
|
+
} from 'ecash-lib';
|
|
27
|
+
import { TestRunner } from 'ecash-lib/dist/test/testRunner.js';
|
|
28
|
+
import { Wallet } from 'ecash-wallet';
|
|
29
|
+
import { Agora } from '../src/agora';
|
|
30
|
+
import { AgoraOneshot } from '../src/oneshot';
|
|
31
|
+
import { getAgoraPaymentAction } from '../src/actions';
|
|
32
|
+
|
|
33
|
+
use(chaiAsPromised);
|
|
34
|
+
|
|
35
|
+
// Configure available satoshis
|
|
36
|
+
const NUM_COINS = 500;
|
|
37
|
+
const COIN_VALUE = 1100000000n;
|
|
38
|
+
|
|
39
|
+
describe('We can use ecash-wallet to create desired on-spec Agora txs', () => {
|
|
40
|
+
let runner: TestRunner;
|
|
41
|
+
let chronik: ChronikClient;
|
|
42
|
+
|
|
43
|
+
before(async () => {
|
|
44
|
+
// Setup using ecash-agora_base so we have agora plugin available
|
|
45
|
+
// ecash-wallet will support agora txs
|
|
46
|
+
runner = await TestRunner.setup('setup_scripts/ecash-agora_base');
|
|
47
|
+
chronik = runner.chronik;
|
|
48
|
+
await runner.setupCoins(NUM_COINS, COIN_VALUE);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
after(() => {
|
|
52
|
+
runner.stop();
|
|
53
|
+
});
|
|
54
|
+
it('We can handle ALP ALP_TOKEN_TYPE_STANDARD agora actions', async () => {
|
|
55
|
+
// Init the wallet
|
|
56
|
+
const alpWallet = Wallet.fromSk(fromHex('14'.repeat(32)), chronik);
|
|
57
|
+
|
|
58
|
+
// Send 1M XEC to the wallet
|
|
59
|
+
const inputSats = 1_000_000_00n;
|
|
60
|
+
await runner.sendToScript(inputSats, alpWallet.script);
|
|
61
|
+
|
|
62
|
+
// Sync the wallet
|
|
63
|
+
await alpWallet.sync();
|
|
64
|
+
|
|
65
|
+
// We can GENESIS a fungible token with multiple mint quantities and multiple mint batons
|
|
66
|
+
const alpGenesisInfo = {
|
|
67
|
+
tokenTicker: 'ALP',
|
|
68
|
+
tokenName: 'ALP Test Token',
|
|
69
|
+
url: 'cashtab.com',
|
|
70
|
+
decimals: 0,
|
|
71
|
+
/** ALP allows arbitrary data in genesis */
|
|
72
|
+
data: 'deadbeef',
|
|
73
|
+
authPubkey: toHex(alpWallet.pk),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const genesisMintQtyAlpha = 1_000n;
|
|
77
|
+
const genesisMintQtyBeta = 2_000n;
|
|
78
|
+
|
|
79
|
+
// Construct the Action for this tx
|
|
80
|
+
const alpGenesisAction: payment.Action = {
|
|
81
|
+
outputs: [
|
|
82
|
+
/** Blank OP_RETURN at outIdx 0 */
|
|
83
|
+
{ sats: 0n },
|
|
84
|
+
/** Misc XEC output at outIdx 1, there is no spec req in ALP for genesis qty at outIdx 1 */
|
|
85
|
+
{ sats: 5_555n, script: alpWallet.script },
|
|
86
|
+
/** Mint qty at outIdx 2 for a token we do not have */
|
|
87
|
+
{
|
|
88
|
+
sats: 546n,
|
|
89
|
+
script: alpWallet.script,
|
|
90
|
+
tokenId: payment.GENESIS_TOKEN_ID_PLACEHOLDER,
|
|
91
|
+
atoms: genesisMintQtyAlpha,
|
|
92
|
+
},
|
|
93
|
+
/** Another misc XEC output at outIdx 2, to show we support non-consecutive mint quantities */
|
|
94
|
+
{ sats: 3_333n, script: alpWallet.script },
|
|
95
|
+
/** Mint qty at outIdx 3 */
|
|
96
|
+
{
|
|
97
|
+
sats: 546n,
|
|
98
|
+
script: alpWallet.script,
|
|
99
|
+
tokenId: payment.GENESIS_TOKEN_ID_PLACEHOLDER,
|
|
100
|
+
atoms: genesisMintQtyBeta,
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* Another misc XEC output at outIdx 4, to show
|
|
104
|
+
* that mintBaton outIdx does not necessarily
|
|
105
|
+
* immediately follow mint qty */
|
|
106
|
+
{ sats: 5_555n, script: alpWallet.script },
|
|
107
|
+
/** Mint baton at outIdx 5 */
|
|
108
|
+
{
|
|
109
|
+
sats: 546n,
|
|
110
|
+
script: alpWallet.script,
|
|
111
|
+
tokenId: payment.GENESIS_TOKEN_ID_PLACEHOLDER,
|
|
112
|
+
isMintBaton: true,
|
|
113
|
+
atoms: 0n,
|
|
114
|
+
},
|
|
115
|
+
/** Another mint baton at outIdx 6 */
|
|
116
|
+
{
|
|
117
|
+
sats: 546n,
|
|
118
|
+
script: alpWallet.script,
|
|
119
|
+
tokenId: payment.GENESIS_TOKEN_ID_PLACEHOLDER,
|
|
120
|
+
isMintBaton: true,
|
|
121
|
+
atoms: 0n,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
tokenActions: [
|
|
125
|
+
{
|
|
126
|
+
type: 'GENESIS',
|
|
127
|
+
tokenType: {
|
|
128
|
+
protocol: 'ALP',
|
|
129
|
+
type: 'ALP_TOKEN_TYPE_STANDARD',
|
|
130
|
+
number: 0,
|
|
131
|
+
},
|
|
132
|
+
genesisInfo: alpGenesisInfo,
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Build and broadcast
|
|
138
|
+
const resp = await alpWallet
|
|
139
|
+
.action(alpGenesisAction)
|
|
140
|
+
.build()
|
|
141
|
+
.broadcast();
|
|
142
|
+
|
|
143
|
+
const alpGenesisTokenId = resp.broadcasted[0];
|
|
144
|
+
|
|
145
|
+
// We can list an ALP token with an agora partial
|
|
146
|
+
const agora = new Agora(chronik);
|
|
147
|
+
|
|
148
|
+
// Use selectParams to get an agora partial with the correct params
|
|
149
|
+
const alpAgoraPartial = await agora.selectParams({
|
|
150
|
+
offeredAtoms: genesisMintQtyAlpha,
|
|
151
|
+
priceNanoSatsPerAtom: 1_000_000_000n, // i.e. 1 sat per atom
|
|
152
|
+
makerPk: alpWallet.pk,
|
|
153
|
+
minAcceptedAtoms: 546n, // so, min accept is dust
|
|
154
|
+
tokenId: alpGenesisTokenId,
|
|
155
|
+
tokenType: ALP_TOKEN_TYPE_STANDARD.number,
|
|
156
|
+
tokenProtocol: 'ALP',
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Get the payment action
|
|
160
|
+
const alpListPaymentAction = getAgoraPaymentAction({
|
|
161
|
+
type: 'LIST',
|
|
162
|
+
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
163
|
+
variant: { type: 'PARTIAL', params: alpAgoraPartial },
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Broadcast the agora LIST
|
|
167
|
+
await alpWallet.action(alpListPaymentAction).build().broadcast();
|
|
168
|
+
|
|
169
|
+
// Verify we can find the listing with Agora
|
|
170
|
+
const activeListingsByTokenId = await agora.activeOffersByTokenId(
|
|
171
|
+
alpGenesisTokenId,
|
|
172
|
+
);
|
|
173
|
+
expect(activeListingsByTokenId.length).to.equal(1);
|
|
174
|
+
expect(activeListingsByTokenId[0].token.tokenId).to.equal(
|
|
175
|
+
alpGenesisTokenId,
|
|
176
|
+
);
|
|
177
|
+
});
|
|
178
|
+
it('We cannot handle SLP SLP_TOKEN_TYPE_FUNGIBLE agora actions', async () => {
|
|
179
|
+
// Create a partial
|
|
180
|
+
// We can list an ALP token with an agora partial
|
|
181
|
+
const agora = new Agora(chronik);
|
|
182
|
+
|
|
183
|
+
// Use selectParams to get an agora partial with the correct params
|
|
184
|
+
const slpFungibleAgoraPartial = await agora.selectParams({
|
|
185
|
+
offeredAtoms: 5_000n,
|
|
186
|
+
priceNanoSatsPerAtom: 1_000_000_000n, // i.e. 1 sat per atom
|
|
187
|
+
makerPk: fromHex('04' + '13'.repeat(64)),
|
|
188
|
+
minAcceptedAtoms: 546n, // so, min accept is dust
|
|
189
|
+
tokenId: '11'.repeat(32),
|
|
190
|
+
tokenType: SLP_TOKEN_TYPE_FUNGIBLE.number,
|
|
191
|
+
tokenProtocol: 'SLP',
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// We throw expected error if we try to LIST
|
|
195
|
+
expect(() =>
|
|
196
|
+
getAgoraPaymentAction({
|
|
197
|
+
type: 'LIST',
|
|
198
|
+
tokenType: SLP_TOKEN_TYPE_FUNGIBLE,
|
|
199
|
+
variant: { type: 'PARTIAL', params: slpFungibleAgoraPartial },
|
|
200
|
+
}),
|
|
201
|
+
).to.throw('SLP is not currently supported.');
|
|
202
|
+
});
|
|
203
|
+
it('We cannot handle SLP SLP_TOKEN_TYPE_NFT1_GROUP token actions', async () => {
|
|
204
|
+
// Create a partial
|
|
205
|
+
// We can list an ALP token with an agora partial
|
|
206
|
+
const agora = new Agora(chronik);
|
|
207
|
+
|
|
208
|
+
// Use selectParams to get an agora partial with the correct params
|
|
209
|
+
const slpNft1GroupAgoraPartial = await agora.selectParams({
|
|
210
|
+
offeredAtoms: 1_000n,
|
|
211
|
+
priceNanoSatsPerAtom: 1_000_000_000n, // i.e. 1 sat per atom
|
|
212
|
+
makerPk: fromHex('04' + '13'.repeat(64)),
|
|
213
|
+
minAcceptedAtoms: 546n, // so, min accept is dust
|
|
214
|
+
tokenId: '11'.repeat(32),
|
|
215
|
+
tokenType: SLP_TOKEN_TYPE_NFT1_GROUP.number,
|
|
216
|
+
tokenProtocol: 'SLP',
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Expect error because we do not support minting SLP_TOKEN_TYPE_NFT1_GROUP tokens
|
|
220
|
+
expect(() =>
|
|
221
|
+
getAgoraPaymentAction({
|
|
222
|
+
type: 'LIST',
|
|
223
|
+
tokenType: SLP_TOKEN_TYPE_NFT1_GROUP,
|
|
224
|
+
variant: { type: 'PARTIAL', params: slpNft1GroupAgoraPartial },
|
|
225
|
+
}),
|
|
226
|
+
).to.throw('SLP is not currently supported.');
|
|
227
|
+
});
|
|
228
|
+
it('We cannot handle SLP SLP_TOKEN_TYPE_NFT1_CHILD token actions', async () => {
|
|
229
|
+
// Create a ONESHOT offer for this NFT
|
|
230
|
+
const slpNft1GroupOneshot = new AgoraOneshot({
|
|
231
|
+
enforcedOutputs: [
|
|
232
|
+
{
|
|
233
|
+
sats: 0n,
|
|
234
|
+
script: slpSend(
|
|
235
|
+
'11'.repeat(32),
|
|
236
|
+
SLP_TOKEN_TYPE_NFT1_CHILD.number,
|
|
237
|
+
[1n],
|
|
238
|
+
),
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
sats: 10_000n,
|
|
242
|
+
script: Address.p2pkh('11'.repeat(20)).toScript(),
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
cancelPk: fromHex('04' + '13'.repeat(64)),
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
expect(() =>
|
|
249
|
+
getAgoraPaymentAction({
|
|
250
|
+
type: 'LIST',
|
|
251
|
+
tokenType: SLP_TOKEN_TYPE_NFT1_GROUP,
|
|
252
|
+
variant: { type: 'ONESHOT', params: slpNft1GroupOneshot },
|
|
253
|
+
}),
|
|
254
|
+
).to.throw('SLP is not currently supported.');
|
|
255
|
+
});
|
|
256
|
+
it('We cannot handle SLP SLP_TOKEN_TYPE_MINT_VAULT agora actions', async () => {
|
|
257
|
+
// Create a partial
|
|
258
|
+
// We can list an ALP token with an agora partial
|
|
259
|
+
const agora = new Agora(chronik);
|
|
260
|
+
|
|
261
|
+
// Use selectParams to get an agora partial with the correct params
|
|
262
|
+
const slpMintVaultAgoraPartial = await agora.selectParams({
|
|
263
|
+
offeredAtoms: 1_000n,
|
|
264
|
+
priceNanoSatsPerAtom: 1_000_000_000n, // i.e. 1 sat per atom
|
|
265
|
+
makerPk: fromHex('04' + '13'.repeat(64)),
|
|
266
|
+
minAcceptedAtoms: 546n, // so, min accept is dust
|
|
267
|
+
tokenId: '11'.repeat(32),
|
|
268
|
+
tokenType: SLP_TOKEN_TYPE_MINT_VAULT.number,
|
|
269
|
+
tokenProtocol: 'SLP',
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// Expect error because we do not support MINT for SLP_TOKEN_TYPE_MINT_VAULT tokens
|
|
273
|
+
expect(() =>
|
|
274
|
+
getAgoraPaymentAction({
|
|
275
|
+
type: 'LIST',
|
|
276
|
+
tokenType: SLP_TOKEN_TYPE_MINT_VAULT,
|
|
277
|
+
variant: { type: 'PARTIAL', params: slpMintVaultAgoraPartial },
|
|
278
|
+
}),
|
|
279
|
+
).to.throw('SLP is not currently supported.');
|
|
280
|
+
});
|
|
281
|
+
});
|