@1sat/actions 0.0.234 → 0.1.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/dist/1color/deploy.d.ts +35 -0
- package/dist/1color/deploy.d.ts.map +1 -0
- package/dist/1color/deploy.js +127 -0
- package/dist/1color/deploy.js.map +1 -0
- package/dist/{mandala → 1color}/deploy.test.d.ts.map +1 -1
- package/dist/1color/deploy.test.js +188 -0
- package/dist/1color/deploy.test.js.map +1 -0
- package/dist/1color/index.d.ts +10 -0
- package/dist/{mandala → 1color}/index.d.ts.map +1 -1
- package/dist/1color/index.js +12 -0
- package/dist/1color/index.js.map +1 -0
- package/dist/1color/receipt.d.ts +39 -0
- package/dist/1color/receipt.d.ts.map +1 -0
- package/dist/1color/receipt.js +91 -0
- package/dist/1color/receipt.js.map +1 -0
- package/dist/1color/send.d.ts +52 -0
- package/dist/1color/send.d.ts.map +1 -0
- package/dist/1color/send.js +175 -0
- package/dist/1color/send.js.map +1 -0
- package/dist/{mandala → 1color}/send.test.d.ts.map +1 -1
- package/dist/1color/send.test.js +622 -0
- package/dist/1color/send.test.js.map +1 -0
- package/dist/addresses/index.js +1 -1
- package/dist/addresses/index.js.map +1 -1
- package/dist/apply/inscribeSigma.js +2 -2
- package/dist/apply/inscribeSigma.js.map +1 -1
- package/dist/collections/index.js +3 -3
- package/dist/collections/index.js.map +1 -1
- package/dist/cosign/buildDestination.js +1 -1
- package/dist/cosign/buildDestination.js.map +1 -1
- package/dist/funding/walletFunding.d.ts +1 -2
- package/dist/funding/walletFunding.d.ts.map +1 -1
- package/dist/funding/walletFunding.js +2 -3
- package/dist/funding/walletFunding.js.map +1 -1
- package/dist/identity/index.js +1 -1
- package/dist/identity/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/listings/cancelOwnedListings.d.ts.map +1 -1
- package/dist/listings/cancelOwnedListings.js +7 -3
- package/dist/listings/cancelOwnedListings.js.map +1 -1
- package/dist/locks/index.d.ts.map +1 -1
- package/dist/locks/index.js +3 -2
- package/dist/locks/index.js.map +1 -1
- package/dist/metanet/delivery.d.ts +69 -0
- package/dist/metanet/delivery.d.ts.map +1 -0
- package/dist/metanet/delivery.js +235 -0
- package/dist/metanet/delivery.js.map +1 -0
- package/dist/metanet/delivery.test.d.ts +2 -0
- package/dist/metanet/delivery.test.d.ts.map +1 -0
- package/dist/metanet/delivery.test.js +125 -0
- package/dist/metanet/delivery.test.js.map +1 -0
- package/dist/metanet/envelope.test.js +1 -1
- package/dist/metanet/envelope.test.js.map +1 -1
- package/dist/metanet/inbox.d.ts +2 -2
- package/dist/metanet/inbox.js +2 -2
- package/dist/metanet/index.d.ts +5 -3
- package/dist/metanet/index.d.ts.map +1 -1
- package/dist/metanet/index.js +6 -4
- package/dist/metanet/index.js.map +1 -1
- package/dist/metanet/receive.d.ts +46 -16
- package/dist/metanet/receive.d.ts.map +1 -1
- package/dist/metanet/receive.js +118 -17
- package/dist/metanet/receive.js.map +1 -1
- package/dist/metanet/relay.d.ts +1 -1
- package/dist/metanet/relay.js +1 -1
- package/dist/metanet/testdata/brc232-vectors.json +86 -0
- package/dist/mnee/index.js +1 -1
- package/dist/mnee/index.js.map +1 -1
- package/dist/opns/index.d.ts.map +1 -1
- package/dist/opns/index.js +8 -9
- package/dist/opns/index.js.map +1 -1
- package/dist/opns/registerOpns.test.js +3 -2
- package/dist/opns/registerOpns.test.js.map +1 -1
- package/dist/ordfs/dir.js +1 -1
- package/dist/ordfs/dir.js.map +1 -1
- package/dist/ordfs/index.d.ts +0 -1
- package/dist/ordfs/index.d.ts.map +1 -1
- package/dist/ordfs/index.js +0 -1
- package/dist/ordfs/index.js.map +1 -1
- package/dist/ordfs/patch.js +1 -1
- package/dist/ordfs/patch.js.map +1 -1
- package/dist/ordinals/index.d.ts.map +1 -1
- package/dist/ordinals/index.js +7 -6
- package/dist/ordinals/index.js.map +1 -1
- package/dist/payments/index.d.ts +1 -1
- package/dist/payments/index.js +3 -3
- package/dist/payments/index.js.map +1 -1
- package/dist/payments/sendBsvHandle.test.js +52 -34
- package/dist/payments/sendBsvHandle.test.js.map +1 -1
- package/dist/pipeline/spendTargets.d.ts.map +1 -1
- package/dist/pipeline/spendTargets.js +2 -7
- package/dist/pipeline/spendTargets.js.map +1 -1
- package/dist/signing/aip.js +2 -2
- package/dist/signing/aip.js.map +1 -1
- package/dist/signing/bap.js +1 -1
- package/dist/signing/bap.js.map +1 -1
- package/dist/signing/index.js +1 -1
- package/dist/signing/index.js.map +1 -1
- package/dist/signing/sigma.js +1 -1
- package/dist/signing/sigma.js.map +1 -1
- package/dist/sweep/index.js +5 -5
- package/dist/sweep/index.js.map +1 -1
- package/dist/sweep/scan.d.ts +1 -0
- package/dist/sweep/scan.d.ts.map +1 -1
- package/dist/sweep/scan.js +2 -6
- package/dist/sweep/scan.js.map +1 -1
- package/dist/sweep/transfer.js +2 -2
- package/dist/sweep/transfer.js.map +1 -1
- package/dist/sync/index.js +1 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +3 -3
- package/dist/tokens/index.js.map +1 -1
- package/dist/utils/ordlockCancelLength.js +1 -1
- package/dist/utils/resolveDestination.js +1 -1
- package/dist/utils/resolveDestination.js.map +1 -1
- package/package.json +10 -9
- package/dist/mandala/deploy.d.ts +0 -89
- package/dist/mandala/deploy.d.ts.map +0 -1
- package/dist/mandala/deploy.js +0 -226
- package/dist/mandala/deploy.js.map +0 -1
- package/dist/mandala/deploy.test.js +0 -281
- package/dist/mandala/deploy.test.js.map +0 -1
- package/dist/mandala/index.d.ts +0 -9
- package/dist/mandala/index.js +0 -17
- package/dist/mandala/index.js.map +0 -1
- package/dist/mandala/receive.d.ts +0 -58
- package/dist/mandala/receive.d.ts.map +0 -1
- package/dist/mandala/receive.js +0 -162
- package/dist/mandala/receive.js.map +0 -1
- package/dist/mandala/send.d.ts +0 -74
- package/dist/mandala/send.d.ts.map +0 -1
- package/dist/mandala/send.js +0 -313
- package/dist/mandala/send.js.map +0 -1
- package/dist/mandala/send.test.js +0 -515
- package/dist/mandala/send.test.js.map +0 -1
- package/dist/mandala/tokenId.d.ts +0 -21
- package/dist/mandala/tokenId.d.ts.map +0 -1
- package/dist/mandala/tokenId.js +0 -29
- package/dist/mandala/tokenId.js.map +0 -1
- package/dist/ordfs/outpoint.d.ts +0 -11
- package/dist/ordfs/outpoint.d.ts.map +0 -1
- package/dist/ordfs/outpoint.js +0 -42
- package/dist/ordfs/outpoint.js.map +0 -1
- /package/dist/{mandala → 1color}/deploy.test.d.ts +0 -0
- /package/dist/{mandala → 1color}/send.test.d.ts +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1Color (BRC-162) deploy through the wallet's BRC-207 `color` module.
|
|
3
|
+
*
|
|
4
|
+
* One `createAction`: output 0 is the deploy, locked to the key derived under
|
|
5
|
+
* `colorProtocolID(ISSUE, prefix, suffix)`, keyID `color`, counterparty self;
|
|
6
|
+
* the labels carry the BRC-207 plan (`ColorPlan.toLabels`) naming that output
|
|
7
|
+
* as owned, with one `deploy-fixed` (amount > 0) or `deploy-authority`
|
|
8
|
+
* (amount 0) operation; `randomizeOutputs: false`. The module checks the
|
|
9
|
+
* plan, files the signed deploy into its asset basket and submits it to
|
|
10
|
+
* `tm_color` and the asset's topic. The asset id is `<txid>_0`.
|
|
11
|
+
*/
|
|
12
|
+
import type { Action } from '../types.js';
|
|
13
|
+
export interface Deploy1ColorInput {
|
|
14
|
+
/** Supply: > 0 is a fixed-supply deploy, 0 an authority deploy */
|
|
15
|
+
amount: string | bigint;
|
|
16
|
+
/** Decimal places (`dec`), 0-18 */
|
|
17
|
+
decimals?: number;
|
|
18
|
+
/** Ticker (`sym`); not unique */
|
|
19
|
+
symbol?: string;
|
|
20
|
+
/** Icon (`icon`): the image embedded in the deploy, as its media type and bytes */
|
|
21
|
+
icon?: {
|
|
22
|
+
mediaType: string;
|
|
23
|
+
bytes: number[] | Uint8Array;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface Deploy1ColorResponse {
|
|
27
|
+
txid?: string;
|
|
28
|
+
/** AtomicBEEF of the deploy transaction */
|
|
29
|
+
tx?: number[];
|
|
30
|
+
/** The asset id, `<txid>_0` */
|
|
31
|
+
assetId?: string;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare const deploy1Color: Action<Deploy1ColorInput, Deploy1ColorResponse>;
|
|
35
|
+
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/1color/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,WAAW,iBAAiB;IACjC,kEAAkE;IAClE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mFAAmF;IACnF,IAAI,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;KAAE,CAAA;CAC1D;AAED,MAAM,WAAW,oBAAoB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2CAA2C;IAC3C,EAAE,CAAC,EAAE,MAAM,EAAE,CAAA;IACb,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAkHxE,CAAA"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1Color (BRC-162) deploy through the wallet's BRC-207 `color` module.
|
|
3
|
+
*
|
|
4
|
+
* One `createAction`: output 0 is the deploy, locked to the key derived under
|
|
5
|
+
* `colorProtocolID(ISSUE, prefix, suffix)`, keyID `color`, counterparty self;
|
|
6
|
+
* the labels carry the BRC-207 plan (`ColorPlan.toLabels`) naming that output
|
|
7
|
+
* as owned, with one `deploy-fixed` (amount > 0) or `deploy-authority`
|
|
8
|
+
* (amount 0) operation; `randomizeOutputs: false`. The module checks the
|
|
9
|
+
* plan, files the signed deploy into its asset basket and submits it to
|
|
10
|
+
* `tm_color` and the asset's topic. The asset id is `<txid>_0`.
|
|
11
|
+
*/
|
|
12
|
+
import { OneColor } from '@1sat/templates';
|
|
13
|
+
import { COLOR_KEY_ID, ColorPlan, ISSUE, colorProtocolID, } from '@bsv/color-permission-module';
|
|
14
|
+
import { PublicKey } from '@bsv/sdk';
|
|
15
|
+
import { randomBase64 } from '../metanet/deliver.js';
|
|
16
|
+
export const deploy1Color = {
|
|
17
|
+
meta: {
|
|
18
|
+
name: 'deploy1Color',
|
|
19
|
+
description: "Deploy a 1Color (BRC-162) token through the wallet's BRC-207 color module: amount > 0 is fixed supply, 0 is an authority deploy. The asset id is <txid>_0.",
|
|
20
|
+
category: 'tokens',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
amount: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'Supply as a string for bigint: > 0 fixed supply, 0 authority deploy',
|
|
27
|
+
},
|
|
28
|
+
decimals: {
|
|
29
|
+
type: 'integer',
|
|
30
|
+
description: 'Decimal places (0-18)',
|
|
31
|
+
},
|
|
32
|
+
symbol: { type: 'string', description: 'Token symbol/ticker' },
|
|
33
|
+
icon: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
description: 'Icon embedded in the deploy: { mediaType (e.g. image/png), bytes (array of byte values) }',
|
|
36
|
+
properties: {
|
|
37
|
+
mediaType: { type: 'string' },
|
|
38
|
+
bytes: { type: 'array', items: { type: 'integer' } },
|
|
39
|
+
},
|
|
40
|
+
required: ['mediaType', 'bytes'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
required: ['amount'],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
async execute(ctx, input) {
|
|
47
|
+
try {
|
|
48
|
+
const amount = typeof input.amount === 'string' ? BigInt(input.amount) : input.amount;
|
|
49
|
+
const authority = amount === 0n;
|
|
50
|
+
const derivationPrefix = randomBase64();
|
|
51
|
+
const derivationSuffix = randomBase64();
|
|
52
|
+
const { publicKey: identityKey } = await ctx.wallet.getPublicKey({
|
|
53
|
+
identityKey: true,
|
|
54
|
+
});
|
|
55
|
+
const { publicKey } = await ctx.wallet.getPublicKey({
|
|
56
|
+
protocolID: colorProtocolID(ISSUE, derivationPrefix, derivationSuffix),
|
|
57
|
+
keyID: COLOR_KEY_ID,
|
|
58
|
+
counterparty: 'self',
|
|
59
|
+
forSelf: true,
|
|
60
|
+
});
|
|
61
|
+
const lock = PublicKey.fromString(publicKey).toHash();
|
|
62
|
+
const payload = {};
|
|
63
|
+
if (input.symbol !== undefined)
|
|
64
|
+
payload.sym = input.symbol;
|
|
65
|
+
if (input.decimals !== undefined)
|
|
66
|
+
payload.dec = input.decimals;
|
|
67
|
+
if (input.icon !== undefined) {
|
|
68
|
+
payload.icon = {
|
|
69
|
+
mediaType: input.icon.mediaType,
|
|
70
|
+
bytes: Uint8Array.from(input.icon.bytes),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const deploy = authority
|
|
74
|
+
? OneColor.deployAuthority({ lock, payload })
|
|
75
|
+
: OneColor.deployValue(amount, { lock, payload });
|
|
76
|
+
const args = {
|
|
77
|
+
description: authority
|
|
78
|
+
? 'Deploy 1Color token (authority)'
|
|
79
|
+
: 'Deploy 1Color token (fixed supply)',
|
|
80
|
+
outputs: [
|
|
81
|
+
{
|
|
82
|
+
lockingScript: deploy.lock().toHex(),
|
|
83
|
+
satoshis: 1,
|
|
84
|
+
outputDescription: '1Color deploy',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
labels: ColorPlan.toLabels({
|
|
88
|
+
version: 1,
|
|
89
|
+
assets: [ISSUE],
|
|
90
|
+
ownedOutputs: [
|
|
91
|
+
{
|
|
92
|
+
outputIndex: 0,
|
|
93
|
+
assetId: ISSUE,
|
|
94
|
+
derivationPrefix,
|
|
95
|
+
derivationSuffix,
|
|
96
|
+
senderIdentityKey: identityKey,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
operations: [
|
|
100
|
+
{
|
|
101
|
+
assetId: ISSUE,
|
|
102
|
+
operation: authority ? 'deploy-authority' : 'deploy-fixed',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
inputPositions: [],
|
|
106
|
+
changePositions: [],
|
|
107
|
+
sighashTypes: [],
|
|
108
|
+
}),
|
|
109
|
+
options: { randomizeOutputs: false },
|
|
110
|
+
};
|
|
111
|
+
const created = await ctx.wallet.createAction(args);
|
|
112
|
+
if (!created.txid || !created.tx)
|
|
113
|
+
return { error: 'no-transaction' };
|
|
114
|
+
return {
|
|
115
|
+
txid: created.txid,
|
|
116
|
+
tx: Array.from(created.tx),
|
|
117
|
+
assetId: `${created.txid}_0`,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
return {
|
|
122
|
+
error: error instanceof Error ? error.message : String(error),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/1color/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAyB,MAAM,iBAAiB,CAAA;AACjE,OAAO,EACN,YAAY,EACZ,SAAS,EACT,KAAK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AAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC7D,CAAA;QACF,CAAC;IACF,CAAC;CACD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.test.d.ts","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"deploy.test.d.ts","sourceRoot":"","sources":["../../src/1color/deploy.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { OneColor } from '@1sat/templates';
|
|
3
|
+
import { COLOR_KEY_ID, ColorPermissionModule, ColorPlan, ISSUE, colorProtocolID, } from '@bsv/color-permission-module';
|
|
4
|
+
import { LockingScript, MerklePath, P2PKH, PrivateKey, ProtoWallet, PublicKey, Transaction, UnlockingScript, } from '@bsv/sdk';
|
|
5
|
+
import { deploy1Color } from './deploy.js';
|
|
6
|
+
const KEY = PrivateKey.fromHex('01'.repeat(32));
|
|
7
|
+
const IDENTITY = KEY.toPublicKey().toString();
|
|
8
|
+
const proto = new ProtoWallet(KEY);
|
|
9
|
+
/** Fake wallet: createAction builds the outputs into a real tx; nothing else is allowed. */
|
|
10
|
+
function setup() {
|
|
11
|
+
const created = [];
|
|
12
|
+
const other = [];
|
|
13
|
+
const wallet = {
|
|
14
|
+
getPublicKey: (a) => proto.getPublicKey(a),
|
|
15
|
+
createAction: async (args) => {
|
|
16
|
+
created.push(args);
|
|
17
|
+
const parent = new Transaction();
|
|
18
|
+
parent.addInput({
|
|
19
|
+
sourceTXID: '11'.repeat(32),
|
|
20
|
+
sourceOutputIndex: 0,
|
|
21
|
+
unlockingScript: new UnlockingScript(),
|
|
22
|
+
sequence: 0xffffffff,
|
|
23
|
+
});
|
|
24
|
+
parent.addOutput({
|
|
25
|
+
lockingScript: new P2PKH().lock(PrivateKey.fromHex('05'.repeat(32)).toPublicKey().toAddress()),
|
|
26
|
+
satoshis: 100_000,
|
|
27
|
+
});
|
|
28
|
+
parent.merklePath = new MerklePath(100, [
|
|
29
|
+
[{ offset: 0, hash: parent.id('hex'), txid: true }],
|
|
30
|
+
]);
|
|
31
|
+
const tx = new Transaction();
|
|
32
|
+
tx.addInput({
|
|
33
|
+
sourceTransaction: parent,
|
|
34
|
+
sourceOutputIndex: 0,
|
|
35
|
+
unlockingScript: new UnlockingScript(),
|
|
36
|
+
sequence: 0xffffffff,
|
|
37
|
+
});
|
|
38
|
+
for (const o of args.outputs ?? []) {
|
|
39
|
+
tx.addOutput({
|
|
40
|
+
lockingScript: LockingScript.fromHex(o.lockingScript),
|
|
41
|
+
satoshis: o.satoshis,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return { txid: tx.id('hex'), tx: tx.toAtomicBEEF() };
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const ctx = {
|
|
48
|
+
wallet: new Proxy(wallet, {
|
|
49
|
+
get(target, prop) {
|
|
50
|
+
if (prop in target)
|
|
51
|
+
return target[prop];
|
|
52
|
+
return () => {
|
|
53
|
+
other.push(String(prop));
|
|
54
|
+
throw new Error(`unexpected wallet call ${String(prop)}`);
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
chain: 'main',
|
|
59
|
+
isBaseWallet: true,
|
|
60
|
+
};
|
|
61
|
+
return { ctx, created, other };
|
|
62
|
+
}
|
|
63
|
+
/** The one createAction, checked exactly; returns its plan and deploy output. */
|
|
64
|
+
async function expectDeployAction(created, operation) {
|
|
65
|
+
expect(created).toHaveLength(1);
|
|
66
|
+
const args = created[0];
|
|
67
|
+
const plan = ColorPlan.fromLabels(args.labels);
|
|
68
|
+
expect(plan).toBeDefined();
|
|
69
|
+
const owned = plan.ownedOutputs[0];
|
|
70
|
+
expect(plan).toEqual({
|
|
71
|
+
version: 1,
|
|
72
|
+
assets: [ISSUE],
|
|
73
|
+
ownedOutputs: [
|
|
74
|
+
{
|
|
75
|
+
outputIndex: 0,
|
|
76
|
+
assetId: ISSUE,
|
|
77
|
+
derivationPrefix: owned.derivationPrefix,
|
|
78
|
+
derivationSuffix: owned.derivationSuffix,
|
|
79
|
+
senderIdentityKey: IDENTITY,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
operations: [{ assetId: ISSUE, operation }],
|
|
83
|
+
inputPositions: [],
|
|
84
|
+
changePositions: [],
|
|
85
|
+
sighashTypes: [],
|
|
86
|
+
});
|
|
87
|
+
// Fresh random base64 remittance strings.
|
|
88
|
+
expect(owned.derivationPrefix).toMatch(/^[A-Za-z0-9+/]{22}==$/);
|
|
89
|
+
expect(owned.derivationSuffix).toMatch(/^[A-Za-z0-9+/]{22}==$/);
|
|
90
|
+
expect(owned.derivationPrefix).not.toBe(owned.derivationSuffix);
|
|
91
|
+
// The labels are exactly the plan's labels: no other label.
|
|
92
|
+
expect(args.labels).toEqual(ColorPlan.toLabels(plan));
|
|
93
|
+
expect(args.options).toEqual({ randomizeOutputs: false });
|
|
94
|
+
expect(args.inputs).toBeUndefined();
|
|
95
|
+
expect(args.inputBEEF).toBeUndefined();
|
|
96
|
+
expect(args.outputs).toHaveLength(1);
|
|
97
|
+
const out = args.outputs[0];
|
|
98
|
+
expect(Object.keys(out).sort()).toEqual([
|
|
99
|
+
'lockingScript',
|
|
100
|
+
'outputDescription',
|
|
101
|
+
'satoshis',
|
|
102
|
+
]);
|
|
103
|
+
expect(out.satoshis).toBe(1);
|
|
104
|
+
// Output 0 is locked to the ISSUE key the module checks: protocol
|
|
105
|
+
// `p color issue <prefixHex> <suffixHex>`, keyID `color`, our own key.
|
|
106
|
+
const { publicKey } = await proto.getPublicKey({
|
|
107
|
+
protocolID: colorProtocolID(ISSUE, owned.derivationPrefix, owned.derivationSuffix),
|
|
108
|
+
keyID: COLOR_KEY_ID,
|
|
109
|
+
counterparty: IDENTITY,
|
|
110
|
+
forSelf: true,
|
|
111
|
+
});
|
|
112
|
+
const token = OneColor.decode(LockingScript.fromHex(out.lockingScript));
|
|
113
|
+
expect(token?.role).toBe('deploy');
|
|
114
|
+
expect(token?.lock.toHex()).toBe(new P2PKH().lock(PublicKey.fromString(publicKey).toAddress()).toHex());
|
|
115
|
+
return { args, plan: plan, token: token };
|
|
116
|
+
}
|
|
117
|
+
describe('deploy1Color', () => {
|
|
118
|
+
test('fixed supply: one createAction carrying the ISSUE plan; no basket, instructions or internalize', async () => {
|
|
119
|
+
const { ctx, created, other } = setup();
|
|
120
|
+
const res = await deploy1Color.execute(ctx, {
|
|
121
|
+
amount: '21000000',
|
|
122
|
+
symbol: 'GOLD',
|
|
123
|
+
decimals: 8,
|
|
124
|
+
});
|
|
125
|
+
expect(res.error).toBeUndefined();
|
|
126
|
+
const { args, token } = await expectDeployAction(created, 'deploy-fixed');
|
|
127
|
+
expect(args.description).toBe('Deploy 1Color token (fixed supply)');
|
|
128
|
+
expect(token.amount).toBe(21000000n);
|
|
129
|
+
expect(token.metadata).toEqual({ sym: 'GOLD', dec: 8 });
|
|
130
|
+
expect(res.assetId).toBe(`${res.txid}_0`);
|
|
131
|
+
expect(Transaction.fromAtomicBEEF(res.tx).id('hex')).toBe(res.txid);
|
|
132
|
+
expect(other).toEqual([]);
|
|
133
|
+
});
|
|
134
|
+
test('authority: amount 0 is a deploy-authority operation', async () => {
|
|
135
|
+
const { ctx, created } = setup();
|
|
136
|
+
const res = await deploy1Color.execute(ctx, { amount: 0n });
|
|
137
|
+
expect(res.error).toBeUndefined();
|
|
138
|
+
const { args, token } = await expectDeployAction(created, 'deploy-authority');
|
|
139
|
+
expect(args.description).toBe('Deploy 1Color token (authority)');
|
|
140
|
+
expect(token.amount).toBe(0n);
|
|
141
|
+
expect(token.payload).toBeUndefined();
|
|
142
|
+
});
|
|
143
|
+
test('the icon is embedded as [mediaType, bytes]', async () => {
|
|
144
|
+
const { ctx, created } = setup();
|
|
145
|
+
const res = await deploy1Color.execute(ctx, {
|
|
146
|
+
amount: '1',
|
|
147
|
+
icon: { mediaType: 'image/png', bytes: [0x89, 0x50, 0x4e, 0x47] },
|
|
148
|
+
});
|
|
149
|
+
expect(res.error).toBeUndefined();
|
|
150
|
+
const { token } = await expectDeployAction(created, 'deploy-fixed');
|
|
151
|
+
expect(token.metadata).toEqual({
|
|
152
|
+
icon: {
|
|
153
|
+
mediaType: 'image/png',
|
|
154
|
+
bytes: Uint8Array.of(0x89, 0x50, 0x4e, 0x47),
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
expect(token.payloadMap?.icon).toEqual([
|
|
158
|
+
'image/png',
|
|
159
|
+
Uint8Array.of(0x89, 0x50, 0x4e, 0x47),
|
|
160
|
+
]);
|
|
161
|
+
});
|
|
162
|
+
test("the color module's createAction handler accepts the request as an owned deploy", async () => {
|
|
163
|
+
const { ctx, created } = setup();
|
|
164
|
+
await deploy1Color.execute(ctx, { amount: '5' });
|
|
165
|
+
const module = new ColorPermissionModule({
|
|
166
|
+
wallet: proto,
|
|
167
|
+
provider: {},
|
|
168
|
+
requestTokenAccess: async () => true,
|
|
169
|
+
});
|
|
170
|
+
const { args } = (await module.onRequest({
|
|
171
|
+
method: 'createAction',
|
|
172
|
+
args: created[0],
|
|
173
|
+
originator: 'app.example',
|
|
174
|
+
}));
|
|
175
|
+
// The module keeps the plan and adds the encrypted custody of the
|
|
176
|
+
// owned deploy; it adds no inputs (it funds no token value here).
|
|
177
|
+
expect(args.labels).toEqual(created[0].labels);
|
|
178
|
+
expect(args.outputs?.[0].lockingScript).toBe(created[0].outputs?.[0].lockingScript);
|
|
179
|
+
expect(typeof args.outputs?.[0].customInstructions).toBe('string');
|
|
180
|
+
});
|
|
181
|
+
test('a bad decimals value fails before createAction', async () => {
|
|
182
|
+
const { ctx, created } = setup();
|
|
183
|
+
const res = await deploy1Color.execute(ctx, { amount: '1', decimals: 19 });
|
|
184
|
+
expect(res.error).toBe('dec must be an integer 0-18');
|
|
185
|
+
expect(created).toHaveLength(0);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
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
|
+
* `syncTransactionInbox`.
|
|
5
|
+
*/
|
|
6
|
+
export * from './deploy.js';
|
|
7
|
+
export * from './send.js';
|
|
8
|
+
export * from './receipt.js';
|
|
9
|
+
export declare const oneColorActions: (import("../types.js").Action<import("./deploy.js").Deploy1ColorInput, import("./deploy.js").Deploy1ColorResponse> | import("../types.js").Action<import("./send.js").Send1ColorInput, import("./send.js").Send1ColorResult>)[];
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/1color/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAE5B,eAAO,MAAM,eAAe,iOAA6B,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1Color (BRC-162) token actions over the wallet's BRC-207 `color` module:
|
|
3
|
+
* deploy, and send to a BRC-169 handle (delivered per BRC-232). Receipt is
|
|
4
|
+
* `syncTransactionInbox`.
|
|
5
|
+
*/
|
|
6
|
+
import { deploy1Color } from './deploy.js';
|
|
7
|
+
import { send1Color } from './send.js';
|
|
8
|
+
export * from './deploy.js';
|
|
9
|
+
export * from './send.js';
|
|
10
|
+
export * from './receipt.js';
|
|
11
|
+
export const oneColorActions = [deploy1Color, send1Color];
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/1color/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAE5B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BRC-207 receipt instructions: the `customInstructions` of a `basket
|
|
3
|
+
* insertion` into `p color <assetTag>` (or `… authority`), as BRC-232
|
|
4
|
+
* carries them and `internalizeAction` takes them.
|
|
5
|
+
*
|
|
6
|
+
* The string is exactly the JSON `{"version":1,"assetId":"<txid>_<vout>",
|
|
7
|
+
* "derivationPrefix":…,"derivationSuffix":…,"senderIdentityKey":"<66 hex>"}`
|
|
8
|
+
* with these members in this order and nothing else.
|
|
9
|
+
*/
|
|
10
|
+
import { type TokenRole } from '@bsv/color-permission-module';
|
|
11
|
+
import type { Transaction } from '@bsv/sdk';
|
|
12
|
+
/** Receipt facts for one received 1Color output. */
|
|
13
|
+
export interface ColorReceipt {
|
|
14
|
+
/** Canonical asset id `<txid>_<vout>` */
|
|
15
|
+
assetId: string;
|
|
16
|
+
derivationPrefix: string;
|
|
17
|
+
derivationSuffix: string;
|
|
18
|
+
/** Compressed public key, 66 lowercase hex */
|
|
19
|
+
senderIdentityKey: string;
|
|
20
|
+
}
|
|
21
|
+
/** The exact receipt JSON string for `receipt`. */
|
|
22
|
+
export declare function colorReceiptInstructions(receipt: ColorReceipt): string;
|
|
23
|
+
/**
|
|
24
|
+
* Parse receipt instructions, accepting only the exact string
|
|
25
|
+
* {@link colorReceiptInstructions} produces (so no other members, no
|
|
26
|
+
* duplicate members, no whitespace, no `ISSUE`).
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseColorReceipt(customInstructions: string): ColorReceipt;
|
|
29
|
+
/**
|
|
30
|
+
* Check one received `basket insertion` into a `p color` basket against the
|
|
31
|
+
* subject transaction: the basket names the receipt's asset and the output's
|
|
32
|
+
* role, and the output is a 1Color output of that asset. Returns the asset
|
|
33
|
+
* and role; the wallet's module performs the ownership and admission checks.
|
|
34
|
+
*/
|
|
35
|
+
export declare function checkColorReceipt(subject: Transaction, outputIndex: number, basket: string, customInstructions: string): {
|
|
36
|
+
assetId: string;
|
|
37
|
+
role: TokenRole;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receipt.d.ts","sourceRoot":"","sources":["../../src/1color/receipt.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAEN,KAAK,SAAS,EAId,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC5B,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,MAAM,CAAA;IACxB,8CAA8C;IAC9C,iBAAiB,EAAE,MAAM,CAAA;CACzB;AAID,mDAAmD;AACnD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAQtE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,kBAAkB,EAAE,MAAM,GAAG,YAAY,CAwC1E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,MAAM,GACxB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CA4BtC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BRC-207 receipt instructions: the `customInstructions` of a `basket
|
|
3
|
+
* insertion` into `p color <assetTag>` (or `… authority`), as BRC-232
|
|
4
|
+
* carries them and `internalizeAction` takes them.
|
|
5
|
+
*
|
|
6
|
+
* The string is exactly the JSON `{"version":1,"assetId":"<txid>_<vout>",
|
|
7
|
+
* "derivationPrefix":…,"derivationSuffix":…,"senderIdentityKey":"<66 hex>"}`
|
|
8
|
+
* with these members in this order and nothing else.
|
|
9
|
+
*/
|
|
10
|
+
import { OneColor } from '@1sat/templates';
|
|
11
|
+
import { ISSUE, assetBasket, colorProtocolID, parseAssetBasket, } from '@bsv/color-permission-module';
|
|
12
|
+
const IDENTITY_KEY = /^0[23][0-9a-f]{64}$/;
|
|
13
|
+
/** The exact receipt JSON string for `receipt`. */
|
|
14
|
+
export function colorReceiptInstructions(receipt) {
|
|
15
|
+
return JSON.stringify({
|
|
16
|
+
version: 1,
|
|
17
|
+
assetId: receipt.assetId,
|
|
18
|
+
derivationPrefix: receipt.derivationPrefix,
|
|
19
|
+
derivationSuffix: receipt.derivationSuffix,
|
|
20
|
+
senderIdentityKey: receipt.senderIdentityKey,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse receipt instructions, accepting only the exact string
|
|
25
|
+
* {@link colorReceiptInstructions} produces (so no other members, no
|
|
26
|
+
* duplicate members, no whitespace, no `ISSUE`).
|
|
27
|
+
*/
|
|
28
|
+
export function parseColorReceipt(customInstructions) {
|
|
29
|
+
let parsed;
|
|
30
|
+
try {
|
|
31
|
+
parsed = JSON.parse(customInstructions);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
throw new Error('BRC-207: receipt customInstructions are not JSON');
|
|
35
|
+
}
|
|
36
|
+
const r = parsed;
|
|
37
|
+
if (r === null ||
|
|
38
|
+
typeof r !== 'object' ||
|
|
39
|
+
Array.isArray(r) ||
|
|
40
|
+
r.version !== 1 ||
|
|
41
|
+
typeof r.assetId !== 'string' ||
|
|
42
|
+
r.assetId === ISSUE ||
|
|
43
|
+
typeof r.derivationPrefix !== 'string' ||
|
|
44
|
+
typeof r.derivationSuffix !== 'string' ||
|
|
45
|
+
typeof r.senderIdentityKey !== 'string' ||
|
|
46
|
+
!IDENTITY_KEY.test(r.senderIdentityKey)) {
|
|
47
|
+
throw new Error('BRC-207: malformed receipt customInstructions');
|
|
48
|
+
}
|
|
49
|
+
const receipt = {
|
|
50
|
+
assetId: r.assetId,
|
|
51
|
+
derivationPrefix: r.derivationPrefix,
|
|
52
|
+
derivationSuffix: r.derivationSuffix,
|
|
53
|
+
senderIdentityKey: r.senderIdentityKey,
|
|
54
|
+
};
|
|
55
|
+
// Validates the asset id and the remittance strings.
|
|
56
|
+
colorProtocolID(receipt.assetId, receipt.derivationPrefix, receipt.derivationSuffix);
|
|
57
|
+
if (colorReceiptInstructions(receipt) !== customInstructions) {
|
|
58
|
+
throw new Error('BRC-207: receipt customInstructions must be exactly {version, assetId, derivationPrefix, derivationSuffix, senderIdentityKey}');
|
|
59
|
+
}
|
|
60
|
+
return receipt;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check one received `basket insertion` into a `p color` basket against the
|
|
64
|
+
* subject transaction: the basket names the receipt's asset and the output's
|
|
65
|
+
* role, and the output is a 1Color output of that asset. Returns the asset
|
|
66
|
+
* and role; the wallet's module performs the ownership and admission checks.
|
|
67
|
+
*/
|
|
68
|
+
export function checkColorReceipt(subject, outputIndex, basket, customInstructions) {
|
|
69
|
+
const target = parseAssetBasket(basket);
|
|
70
|
+
if (!target) {
|
|
71
|
+
throw new Error(`BRC-207: ${basket} is not a per-asset p color basket`);
|
|
72
|
+
}
|
|
73
|
+
const receipt = parseColorReceipt(customInstructions);
|
|
74
|
+
if (receipt.assetId !== target.assetId) {
|
|
75
|
+
throw new Error(`BRC-207: the receipt names ${receipt.assetId}, the basket ${target.assetId}`);
|
|
76
|
+
}
|
|
77
|
+
if (assetBasket(target.assetId, target.role) !== basket) {
|
|
78
|
+
throw new Error(`BRC-207: ${basket} is not a canonical basket name`);
|
|
79
|
+
}
|
|
80
|
+
const script = subject.outputs[outputIndex]?.lockingScript;
|
|
81
|
+
const token = script ? OneColor.decode(script) : null;
|
|
82
|
+
const role = token?.role === 'authority' ? 'authority' : 'value';
|
|
83
|
+
if (!token ||
|
|
84
|
+
token.role === 'deploy' ||
|
|
85
|
+
token.tokenId !== target.assetId ||
|
|
86
|
+
role !== target.role) {
|
|
87
|
+
throw new Error(`output ${outputIndex}: not a 1Color ${target.role} output of ${target.assetId}`);
|
|
88
|
+
}
|
|
89
|
+
return target;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=receipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receipt.js","sourceRoot":"","sources":["../../src/1color/receipt.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EACN,KAAK,EAEL,WAAW,EACX,eAAe,EACf,gBAAgB,GAChB,MAAM,8BAA8B,CAAA;AAarC,MAAM,YAAY,GAAG,qBAAqB,CAAA;AAE1C,mDAAmD;AACnD,MAAM,UAAU,wBAAwB,CAAC,OAAqB;IAC7D,OAAO,IAAI,CAAC,SAAS,CAAC;QACrB,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;KAC5C,CAAC,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,kBAA0B;IAC3D,IAAI,MAAe,CAAA;IACnB,IAAI,CAAC;QACJ,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;IACxC,CAAC;IAAC,MAAM,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;IACpE,CAAC;IACD,MAAM,CAAC,GAAG,MAAiC,CAAA;IAC3C,IACC,CAAC,KAAK,IAAI;QACV,OAAO,CAAC,KAAK,QAAQ;QACrB,KAAK,CAAC,OAAO,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M,CAAC,OAAO,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACd,8BAA8B,OAAO,CAAC,OAAO,gBAAgB,MAAM,CAAC,OAAO,EAAE,CAC7E,CAAA;IACF,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,iCAAiC,CAAC,CAAA;IACrE,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,aAAa,CAAA;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACrD,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAA;IAChE,IACC,CAAC,KAAK;QACN,KAAK,CAAC,IAAI,KAAK,QAAQ;QACvB,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO;QAChC,IAAI,KAAK,MAAM,CAAC,IAAI,EACnB,CAAC;QACF,MAAM,IAAI,KAAK,CACd,UAAU,WAAW,kBAAkB,MAAM,CAAC,IAAI,cAAc,MAAM,CAAC,OAAO,EAAE,CAChF,CAAA;IACF,CAAC;IACD,OAAO,MAAM,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1Color (BRC-162) send to a BRC-169 handle through the wallet's BRC-207
|
|
3
|
+
* `color` module, delivered per BRC-232.
|
|
4
|
+
*
|
|
5
|
+
* 1. Resolve the handle (`resolveHandle`): identity key + messagebox.
|
|
6
|
+
* 2. Derive the recipient's key under `colorProtocolID(assetId, prefix,
|
|
7
|
+
* suffix)` (fresh random base64 prefix and suffix), keyID `color`,
|
|
8
|
+
* counterparty = the recipient, and build the 1Color value output.
|
|
9
|
+
* 3. One `createAction` with that single output, the BRC-207 plan (assets
|
|
10
|
+
* `[assetId]`, no owned outputs, one `transfer`) plus the BRC-177 label
|
|
11
|
+
* `p nosend expiry seconds <n>`, `noSend` and `randomizeOutputs: false`:
|
|
12
|
+
* the handoff. The module selects the token inputs, splits to the exact
|
|
13
|
+
* amount when it has to, signs and asks for consent. The action is not
|
|
14
|
+
* broadcast; the recipient submits it.
|
|
15
|
+
* 4. Delivery: a signed BRC-169 envelope to the resolved messagebox, box
|
|
16
|
+
* `transaction-delivery`, `payment: null`, whose encrypted content is the
|
|
17
|
+
* BRC-232 MIME entity with one `basket insertion` receipt into
|
|
18
|
+
* `p color <assetTag>`.
|
|
19
|
+
*
|
|
20
|
+
* When delivery fails the result carries the error with `txid` and `tx`, so
|
|
21
|
+
* the caller can retry delivery or `abortAction` the send.
|
|
22
|
+
*/
|
|
23
|
+
import type { Action } from '../types.js';
|
|
24
|
+
export interface Send1ColorInput {
|
|
25
|
+
/** The asset id, `<txid>_<vout>` */
|
|
26
|
+
assetId: string;
|
|
27
|
+
/** Amount in raw units */
|
|
28
|
+
amount: bigint | string;
|
|
29
|
+
/** BRC-169 handle: `@handle@domain` or `handle@domain` */
|
|
30
|
+
destination: {
|
|
31
|
+
handle: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* BRC-177 `nosend expiry seconds` for the handoff (default
|
|
35
|
+
* {@link COLOR_SEND_EXPIRY_SECONDS}, one year).
|
|
36
|
+
*/
|
|
37
|
+
expirySeconds?: number;
|
|
38
|
+
/** Optional free text carried as the BRC-232 `memo` */
|
|
39
|
+
memo?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface Send1ColorResult {
|
|
42
|
+
txid?: string;
|
|
43
|
+
/** Atomic BEEF of the send */
|
|
44
|
+
tx?: number[];
|
|
45
|
+
/** `envelope`: BRC-169 envelope to the handle's messagebox, not broadcast */
|
|
46
|
+
delivered?: 'envelope';
|
|
47
|
+
/** Messagebox message id */
|
|
48
|
+
messageId?: string;
|
|
49
|
+
error?: string;
|
|
50
|
+
}
|
|
51
|
+
export declare const send1Color: Action<Send1ColorInput, Send1ColorResult>;
|
|
52
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/1color/send.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAkBH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,MAAM,WAAW,eAAe;IAC/B,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,0BAA0B;IAC1B,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,0DAA0D;IAC1D,WAAW,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IAC/B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,8BAA8B;IAC9B,EAAE,CAAC,EAAE,MAAM,EAAE,CAAA;IACb,6EAA6E;IAC7E,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAyJhE,CAAA"}
|