@swarm-tips/client 0.3.0 → 0.4.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/SBOM.spdx.json +5 -5
- package/dist/agent.d.ts +1 -0
- package/dist/agent.js +13 -5
- package/dist/contracts/generated/shillbot.d.ts +51 -4
- package/dist/contracts/idl/shillbot.json +51 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/shillbot/api.d.ts +25 -0
- package/dist/shillbot/api.js +98 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/SBOM.spdx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"spdxVersion": "SPDX-2.3",
|
|
3
3
|
"dataLicense": "CC0-1.0",
|
|
4
4
|
"SPDXID": "SPDXRef-DOCUMENT",
|
|
5
|
-
"name": "@swarm-tips/client-0.
|
|
6
|
-
"documentNamespace": "https://swarm.tips/sbom/client/0.
|
|
5
|
+
"name": "@swarm-tips/client-0.4.1",
|
|
6
|
+
"documentNamespace": "https://swarm.tips/sbom/client/0.4.1",
|
|
7
7
|
"creationInfo": {
|
|
8
|
-
"created": "2026-11-
|
|
8
|
+
"created": "2026-11-12T07:38:25.259Z",
|
|
9
9
|
"creators": [
|
|
10
10
|
"Tool: sdk/client/scripts/generate-sbom.mjs",
|
|
11
11
|
"Organization: Swarm Tips"
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
{
|
|
16
16
|
"name": "@swarm-tips/client",
|
|
17
17
|
"SPDXID": "SPDXRef-Package",
|
|
18
|
-
"versionInfo": "0.
|
|
19
|
-
"downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.
|
|
18
|
+
"versionInfo": "0.4.1",
|
|
19
|
+
"downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.1",
|
|
20
20
|
"filesAnalyzed": false,
|
|
21
21
|
"licenseConcluded": "MIT",
|
|
22
22
|
"licenseDeclared": "MIT"
|
package/dist/agent.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ export declare class SwarmAgent {
|
|
|
89
89
|
claim: (id: string, sponsor?: string) => Promise<PreparedTransactionResponse>;
|
|
90
90
|
claimAndExecute: (id: string, opts?: ExecuteTaskOptions) => Promise<ExecutedTaskResult>;
|
|
91
91
|
submit: (id: string, body: unknown) => Promise<PreparedTransactionResponse>;
|
|
92
|
+
preflight: <TResponse = unknown>(id: string, body?: unknown) => Promise<TResponse>;
|
|
92
93
|
submitAndExecute: (id: string, contentId: string, opts?: ExecuteTaskOptions) => Promise<ExecutedTaskResult>;
|
|
93
94
|
buildVerify: (id: string) => Promise<PreparedTransactionResponse>;
|
|
94
95
|
verifyAndExecute: (id: string, opts?: {
|
package/dist/agent.js
CHANGED
|
@@ -195,6 +195,7 @@ export class SwarmAgent {
|
|
|
195
195
|
claim: (id, sponsor = "auto") => self.shillbotClient.claimTask(id, sponsor),
|
|
196
196
|
claimAndExecute: (id, opts) => self.executeClaimOrSubmit(id, "claim", undefined, opts),
|
|
197
197
|
submit: (id, body) => self.shillbotClient.submitTask(id, body),
|
|
198
|
+
preflight: (id, body) => self.shillbotClient.preflightTask(id, body),
|
|
198
199
|
submitAndExecute: (id, contentId, opts) => self.executeClaimOrSubmit(id, "submit", contentId, opts),
|
|
199
200
|
buildVerify: (id) => self.shillbotClient.buildVerify(id, {
|
|
200
201
|
payer: self.auth.walletAddress,
|
|
@@ -329,8 +330,7 @@ export class SwarmAgent {
|
|
|
329
330
|
const targetNet = net ?? self.network;
|
|
330
331
|
const tournamentId = opts?.tournamentId ?? ACTIVE_TOURNAMENT_ID[targetNet];
|
|
331
332
|
const limit = opts?.limit ?? 20;
|
|
332
|
-
|
|
333
|
-
return self.gameClient.http.get(`/tournaments/${encodeURIComponent(String(tournamentId))}/leaderboard?limit=${encodeURIComponent(String(limit))}${suffix}`);
|
|
333
|
+
return self.gameClient.http.get(`/leaderboard?tournament_id=${encodeURIComponent(String(tournamentId))}&limit=${encodeURIComponent(String(limit))}`);
|
|
334
334
|
},
|
|
335
335
|
};
|
|
336
336
|
}
|
|
@@ -358,14 +358,19 @@ export class SwarmAgent {
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
catch (err) {
|
|
361
|
-
if (action === "claim" &&
|
|
361
|
+
if ((action === "claim" || action === "submit") &&
|
|
362
362
|
sponsorMode !== "none" &&
|
|
363
363
|
err instanceof SwarmClientError &&
|
|
364
364
|
err.code === "HTTP_ERROR" &&
|
|
365
365
|
(err.status === 400 || err.status === 403 || err.status === 412) &&
|
|
366
366
|
/onboard|agent_state|bootstrap/i.test(err.message)) {
|
|
367
367
|
await this.shillbotClient.onboard();
|
|
368
|
-
|
|
368
|
+
if (action === "claim") {
|
|
369
|
+
prepared = await this.shillbotClient.claimTask(id, sponsorQuery);
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
prepared = await this.shillbotClient.post(`/tasks/${encodeURIComponent(id)}/submit?sponsor=${encodeURIComponent(sponsorQuery)}`, { content_id: contentId, ...(opts?.extra ?? {}) });
|
|
373
|
+
}
|
|
369
374
|
}
|
|
370
375
|
else {
|
|
371
376
|
throw err;
|
|
@@ -513,8 +518,11 @@ export class SwarmAgent {
|
|
|
513
518
|
}
|
|
514
519
|
static adviseNextAction(task, nowMs = Date.now()) {
|
|
515
520
|
const rawState = String(task.state ?? task.status ?? "").trim().toLowerCase();
|
|
521
|
+
const rawPlatform = task.platform;
|
|
522
|
+
const isOnChainAction = rawPlatform === 11 ||
|
|
523
|
+
(typeof rawPlatform === "string" && rawPlatform.trim().toLowerCase() === "onchain_action");
|
|
516
524
|
if (rawState === "open") {
|
|
517
|
-
return { step: "claim" };
|
|
525
|
+
return { step: isOnChainAction ? "submit" : "claim" };
|
|
518
526
|
}
|
|
519
527
|
if (rawState === "claimed") {
|
|
520
528
|
return { step: "submit" };
|
|
@@ -2114,10 +2114,9 @@ export type Shillbot = {
|
|
|
2114
2114
|
{
|
|
2115
2115
|
"name": "switchboardFeed";
|
|
2116
2116
|
"docs": [
|
|
2117
|
-
"
|
|
2118
|
-
"`
|
|
2119
|
-
"
|
|
2120
|
-
"and parsed via `PullFeedAccountData::parse()`."
|
|
2117
|
+
"Required oracle signer (`GlobalState.oracle_authority` or `GlobalState.authority`).",
|
|
2118
|
+
"Field name retained as `switchboard_feed` for Anchor IDL backwards compatibility.",
|
|
2119
|
+
"or `global_state.authority`."
|
|
2121
2120
|
];
|
|
2122
2121
|
}
|
|
2123
2122
|
];
|
|
@@ -2564,6 +2563,19 @@ export type Shillbot = {
|
|
|
2564
2563
|
128
|
|
2565
2564
|
];
|
|
2566
2565
|
},
|
|
2566
|
+
{
|
|
2567
|
+
"name": "taskReopened";
|
|
2568
|
+
"discriminator": [
|
|
2569
|
+
40,
|
|
2570
|
+
56,
|
|
2571
|
+
100,
|
|
2572
|
+
41,
|
|
2573
|
+
172,
|
|
2574
|
+
36,
|
|
2575
|
+
190,
|
|
2576
|
+
61
|
|
2577
|
+
];
|
|
2578
|
+
},
|
|
2567
2579
|
{
|
|
2568
2580
|
"name": "taskVerified";
|
|
2569
2581
|
"discriminator": [
|
|
@@ -2894,6 +2906,11 @@ export type Shillbot = {
|
|
|
2894
2906
|
"code": 6057;
|
|
2895
2907
|
"name": "invalidTimeoutOrdering";
|
|
2896
2908
|
"msg": "verification_timeout must exceed attestation_delay + staleness_window";
|
|
2909
|
+
},
|
|
2910
|
+
{
|
|
2911
|
+
"code": 6058;
|
|
2912
|
+
"name": "invalidInstructionBundle";
|
|
2913
|
+
"msg": "OnChainAction claim must be bundled atomically at top-level with submit_work";
|
|
2897
2914
|
}
|
|
2898
2915
|
];
|
|
2899
2916
|
"types": [
|
|
@@ -4073,6 +4090,36 @@ export type Shillbot = {
|
|
|
4073
4090
|
];
|
|
4074
4091
|
};
|
|
4075
4092
|
},
|
|
4093
|
+
{
|
|
4094
|
+
"name": "taskReopened";
|
|
4095
|
+
"docs": [
|
|
4096
|
+
"Emitted when an `OnChainAction` (`platform == 11`) submission receives a `0`",
|
|
4097
|
+
"score while still claimable (`now + claim_buffer < deadline`) and is reopened",
|
|
4098
|
+
"in-place to `TaskState::Open` rather than entering terminal `Verified(0)`."
|
|
4099
|
+
];
|
|
4100
|
+
"type": {
|
|
4101
|
+
"kind": "struct";
|
|
4102
|
+
"fields": [
|
|
4103
|
+
{
|
|
4104
|
+
"name": "taskId";
|
|
4105
|
+
"type": "u64";
|
|
4106
|
+
},
|
|
4107
|
+
{
|
|
4108
|
+
"name": "prevAgent";
|
|
4109
|
+
"type": "pubkey";
|
|
4110
|
+
},
|
|
4111
|
+
{
|
|
4112
|
+
"name": "verificationHash";
|
|
4113
|
+
"type": {
|
|
4114
|
+
"array": [
|
|
4115
|
+
"u8",
|
|
4116
|
+
32
|
|
4117
|
+
];
|
|
4118
|
+
};
|
|
4119
|
+
}
|
|
4120
|
+
];
|
|
4121
|
+
};
|
|
4122
|
+
},
|
|
4076
4123
|
{
|
|
4077
4124
|
"name": "taskState";
|
|
4078
4125
|
"docs": [
|
|
@@ -2108,10 +2108,9 @@
|
|
|
2108
2108
|
{
|
|
2109
2109
|
"name": "switchboard_feed",
|
|
2110
2110
|
"docs": [
|
|
2111
|
-
"
|
|
2112
|
-
"`
|
|
2113
|
-
"
|
|
2114
|
-
"and parsed via `PullFeedAccountData::parse()`."
|
|
2111
|
+
"Required oracle signer (`GlobalState.oracle_authority` or `GlobalState.authority`).",
|
|
2112
|
+
"Field name retained as `switchboard_feed` for Anchor IDL backwards compatibility.",
|
|
2113
|
+
"or `global_state.authority`."
|
|
2115
2114
|
]
|
|
2116
2115
|
}
|
|
2117
2116
|
],
|
|
@@ -2558,6 +2557,19 @@
|
|
|
2558
2557
|
128
|
|
2559
2558
|
]
|
|
2560
2559
|
},
|
|
2560
|
+
{
|
|
2561
|
+
"name": "TaskReopened",
|
|
2562
|
+
"discriminator": [
|
|
2563
|
+
40,
|
|
2564
|
+
56,
|
|
2565
|
+
100,
|
|
2566
|
+
41,
|
|
2567
|
+
172,
|
|
2568
|
+
36,
|
|
2569
|
+
190,
|
|
2570
|
+
61
|
|
2571
|
+
]
|
|
2572
|
+
},
|
|
2561
2573
|
{
|
|
2562
2574
|
"name": "TaskVerified",
|
|
2563
2575
|
"discriminator": [
|
|
@@ -2888,6 +2900,11 @@
|
|
|
2888
2900
|
"code": 6057,
|
|
2889
2901
|
"name": "InvalidTimeoutOrdering",
|
|
2890
2902
|
"msg": "verification_timeout must exceed attestation_delay + staleness_window"
|
|
2903
|
+
},
|
|
2904
|
+
{
|
|
2905
|
+
"code": 6058,
|
|
2906
|
+
"name": "InvalidInstructionBundle",
|
|
2907
|
+
"msg": "OnChainAction claim must be bundled atomically at top-level with submit_work"
|
|
2891
2908
|
}
|
|
2892
2909
|
],
|
|
2893
2910
|
"types": [
|
|
@@ -4067,6 +4084,36 @@
|
|
|
4067
4084
|
]
|
|
4068
4085
|
}
|
|
4069
4086
|
},
|
|
4087
|
+
{
|
|
4088
|
+
"name": "TaskReopened",
|
|
4089
|
+
"docs": [
|
|
4090
|
+
"Emitted when an `OnChainAction` (`platform == 11`) submission receives a `0`",
|
|
4091
|
+
"score while still claimable (`now + claim_buffer < deadline`) and is reopened",
|
|
4092
|
+
"in-place to `TaskState::Open` rather than entering terminal `Verified(0)`."
|
|
4093
|
+
],
|
|
4094
|
+
"type": {
|
|
4095
|
+
"kind": "struct",
|
|
4096
|
+
"fields": [
|
|
4097
|
+
{
|
|
4098
|
+
"name": "task_id",
|
|
4099
|
+
"type": "u64"
|
|
4100
|
+
},
|
|
4101
|
+
{
|
|
4102
|
+
"name": "prev_agent",
|
|
4103
|
+
"type": "pubkey"
|
|
4104
|
+
},
|
|
4105
|
+
{
|
|
4106
|
+
"name": "verification_hash",
|
|
4107
|
+
"type": {
|
|
4108
|
+
"array": [
|
|
4109
|
+
"u8",
|
|
4110
|
+
32
|
|
4111
|
+
]
|
|
4112
|
+
}
|
|
4113
|
+
}
|
|
4114
|
+
]
|
|
4115
|
+
}
|
|
4116
|
+
},
|
|
4070
4117
|
{
|
|
4071
4118
|
"name": "TaskState",
|
|
4072
4119
|
"docs": [
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export type { SwarmClientErrorCode, SwarmClientErrorOptions } from "./errors.js"
|
|
|
6
6
|
export { SwarmAgent, createSwarmAgent, type ExecuteTaskOptions, type ExecutedTaskResult, type NextTaskAction, type SwarmAgentOptions, type SwarmNetwork, type TaskLifecycleStep, } from "./agent.js";
|
|
7
7
|
export { WalletTokenManager, type TokenProvider, type WalletTokenManagerOptions, } from "./auth/token-manager.js";
|
|
8
8
|
export { fromEvmPrivateKey, fromEvmWalletClient, fromSolanaKeypair, fromSolanaSecretKey, fromSolanaWalletAdapter, redactSigner, type EvmCallRequest, type EvmPrivateKeyOptions, type EvmSwarmSigner, type EvmWalletClientLike, type SolanaSwarmSigner, type SolanaWalletAdapterLike, type SwarmSigner, } from "./signer/index.js";
|
|
9
|
-
export { SHILLBOT_ESCROW_DEPLOYMENTS, SHILLBOT_EVM_SELECTORS, estimateSolanaNetworkFeeLamports, validatePreparedEvmCall, validatePreparedTransaction, type BuildVerifyOptions, type PreparedEvmCallExpectation, type PreparedTransactionExpectation, type PreparedTransactionResponse, type ValidatedEvmCall, type VerificationDataResponse, } from "./shillbot/api.js";
|
|
9
|
+
export { SHILLBOT_ESCROW_DEPLOYMENTS, SHILLBOT_EVM_SELECTORS, buildOnChainActionProofRef, estimateSolanaNetworkFeeLamports, formatOnChainActionAttributionMessage, validatePreparedEvmCall, validatePreparedTransaction, type BuildOnChainActionProofRefParams, type BuildVerifyOptions, type PreparedEvmCallExpectation, type PreparedTransactionExpectation, type PreparedTransactionResponse, type ValidatedEvmCall, type VerificationDataResponse, } from "./shillbot/api.js";
|
|
10
10
|
export { OPENAPI_SERVERS, OPENAPI_VERSION, type OpenApiOperationId, type OpenApiOperations, type OpenApiPaths, type OpenApiSchemas, type OpenApiServerUrl, } from "./generated/openapi.js";
|
package/dist/index.js
CHANGED
|
@@ -5,5 +5,5 @@ export { SwarmClientError } from "./errors.js";
|
|
|
5
5
|
export { SwarmAgent, createSwarmAgent, } from "./agent.js";
|
|
6
6
|
export { WalletTokenManager, } from "./auth/token-manager.js";
|
|
7
7
|
export { fromEvmPrivateKey, fromEvmWalletClient, fromSolanaKeypair, fromSolanaSecretKey, fromSolanaWalletAdapter, redactSigner, } from "./signer/index.js";
|
|
8
|
-
export { SHILLBOT_ESCROW_DEPLOYMENTS, SHILLBOT_EVM_SELECTORS, estimateSolanaNetworkFeeLamports, validatePreparedEvmCall, validatePreparedTransaction, } from "./shillbot/api.js";
|
|
8
|
+
export { SHILLBOT_ESCROW_DEPLOYMENTS, SHILLBOT_EVM_SELECTORS, buildOnChainActionProofRef, estimateSolanaNetworkFeeLamports, formatOnChainActionAttributionMessage, validatePreparedEvmCall, validatePreparedTransaction, } from "./shillbot/api.js";
|
|
9
9
|
export { OPENAPI_SERVERS, OPENAPI_VERSION, } from "./generated/openapi.js";
|
package/dist/shillbot/api.d.ts
CHANGED
|
@@ -63,6 +63,7 @@ export declare class ShillbotApiClient {
|
|
|
63
63
|
unsigned_transaction: string;
|
|
64
64
|
}): Promise<PreparedTransactionResponse>;
|
|
65
65
|
submitTask(id: string, body: unknown): Promise<PreparedTransactionResponse>;
|
|
66
|
+
preflightTask<TResponse = unknown>(id: string, body?: unknown): Promise<TResponse>;
|
|
66
67
|
approveTask(id: string): Promise<PreparedTransactionResponse>;
|
|
67
68
|
getVerificationData(id: string, network?: "mainnet" | "devnet"): Promise<VerificationDataResponse>;
|
|
68
69
|
buildVerify(id: string, opts?: BuildVerifyOptions): Promise<PreparedTransactionResponse>;
|
|
@@ -112,6 +113,30 @@ export declare function permittedPreparedProgramIds(action: Action, network: "ma
|
|
|
112
113
|
* their Connection for that same network before signing.
|
|
113
114
|
*/
|
|
114
115
|
export declare function validatePreparedTransaction(encoded: string, expected: PreparedTransactionExpectation): TransactionInspection;
|
|
116
|
+
export interface BuildOnChainActionProofRefParams {
|
|
117
|
+
/** CAIP-2 target chain ID (e.g. `"eip155:56"`, `"eip155:8453"`, `"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"`). */
|
|
118
|
+
targetChainId: string;
|
|
119
|
+
/** Transaction hash (`0x` + 64 hex chars on EVM) or base58 signature (on Solana). */
|
|
120
|
+
txId: string;
|
|
121
|
+
/** Zero-based log index within the EVM receipt or matched instruction index on Solana. */
|
|
122
|
+
index: number;
|
|
123
|
+
/**
|
|
124
|
+
* Optional 65-byte EIP-191 signature (`0x` + 130 hex chars or `Uint8Array`)
|
|
125
|
+
* over `formatOnChainActionAttributionMessage(targetChainId, agentSolanaPubkey)`
|
|
126
|
+
* binding an EVM referral address to the Solana settlement wallet (`M2a`).
|
|
127
|
+
*/
|
|
128
|
+
attributionSignature?: string | Uint8Array;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Format the canonical EIP-191 message signed by an agent's EVM referral wallet
|
|
132
|
+
* to bind cross-chain EVM conversions to their Solana settlement pubkey (`M2a`).
|
|
133
|
+
*/
|
|
134
|
+
export declare function formatOnChainActionAttributionMessage(targetChainId: string, agentSolanaPubkey: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* Build a canonical `content_id` proof reference for `PlatformType::OnChainAction = 11`:
|
|
137
|
+
* `<caip2>:<tx_id>:<index>[:sig:<base64url_nopad_65B>]`.
|
|
138
|
+
*/
|
|
139
|
+
export declare function buildOnChainActionProofRef(params: BuildOnChainActionProofRefParams): string;
|
|
115
140
|
export declare function signBroadcastPreparedTransaction(input: {
|
|
116
141
|
connection: Connection;
|
|
117
142
|
transaction: string;
|
package/dist/shillbot/api.js
CHANGED
|
@@ -85,6 +85,9 @@ export class ShillbotApiClient {
|
|
|
85
85
|
submitTask(id, body) {
|
|
86
86
|
return this.post(`/tasks/${encodeURIComponent(id)}/submit`, body);
|
|
87
87
|
}
|
|
88
|
+
preflightTask(id, body) {
|
|
89
|
+
return this.post(`/tasks/${encodeURIComponent(id)}/preflight`, body);
|
|
90
|
+
}
|
|
88
91
|
approveTask(id) {
|
|
89
92
|
return this.post(`/tasks/${encodeURIComponent(id)}/approve`);
|
|
90
93
|
}
|
|
@@ -386,15 +389,35 @@ export function validatePreparedTransaction(encoded, expected) {
|
|
|
386
389
|
const shillbotIxs = inspected.instructions.filter((instruction) => instruction.program_id === shillbotId);
|
|
387
390
|
const lifecycle = shillbotIxs.filter((instruction) => matchesDiscriminator(instruction.data_base64, expected.action));
|
|
388
391
|
const companions = shillbotIxs.filter((instruction) => instruction !== lifecycle[0]);
|
|
392
|
+
const claimDisc = shillbotInstructionDiscriminator("claim_task");
|
|
389
393
|
const payoutDisc = shillbotInstructionDiscriminator("set_payout_to");
|
|
394
|
+
const hasDisc = (ix, disc) => Buffer.from(ix.data_base64, "base64").subarray(0, 8).equals(disc);
|
|
395
|
+
const ixPos = (ix) => inspected.instructions.indexOf(ix);
|
|
396
|
+
const validClaimCompanion = (ix) => hasDisc(ix, claimDisc) &&
|
|
397
|
+
ix.accounts.length >= 4 &&
|
|
398
|
+
(!expected.taskPda || ix.accounts[0] === expected.taskPda) &&
|
|
399
|
+
ix.accounts[0] === lifecycle[0]?.accounts[0] &&
|
|
400
|
+
ix.accounts[3] === expected.wallet;
|
|
401
|
+
const validPayoutCompanion = (ix) => hasDisc(ix, payoutDisc) &&
|
|
402
|
+
ix.accounts.length === 2 &&
|
|
403
|
+
(!expected.taskPda || ix.accounts[0] === expected.taskPda) &&
|
|
404
|
+
ix.accounts[0] === lifecycle[0]?.accounts[0] &&
|
|
405
|
+
ix.accounts[1] === expected.wallet;
|
|
390
406
|
const validCompanions = companions.length === 0 ||
|
|
391
407
|
(expected.action === "claim" &&
|
|
392
408
|
companions.length === 1 &&
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
companions[0]
|
|
409
|
+
validPayoutCompanion(companions[0]) &&
|
|
410
|
+
ixPos(companions[0]) > ixPos(lifecycle[0])) ||
|
|
411
|
+
(expected.action === "submit" &&
|
|
412
|
+
companions.length === 1 &&
|
|
413
|
+
validClaimCompanion(companions[0]) &&
|
|
414
|
+
ixPos(lifecycle[0]) === ixPos(companions[0]) + 1) ||
|
|
415
|
+
(expected.action === "submit" &&
|
|
416
|
+
companions.length === 2 &&
|
|
417
|
+
validClaimCompanion(companions[0]) &&
|
|
418
|
+
validPayoutCompanion(companions[1]) &&
|
|
419
|
+
ixPos(companions[1]) === ixPos(companions[0]) + 1 &&
|
|
420
|
+
ixPos(lifecycle[0]) === ixPos(companions[1]) + 1);
|
|
398
421
|
if (lifecycle.length !== 1 || !validCompanions) {
|
|
399
422
|
throw new SwarmClientError({
|
|
400
423
|
code: "TRANSACTION_MISMATCH",
|
|
@@ -445,6 +468,76 @@ export function validatePreparedTransaction(encoded, expected) {
|
|
|
445
468
|
}
|
|
446
469
|
return inspected;
|
|
447
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Format the canonical EIP-191 message signed by an agent's EVM referral wallet
|
|
473
|
+
* to bind cross-chain EVM conversions to their Solana settlement pubkey (`M2a`).
|
|
474
|
+
*/
|
|
475
|
+
export function formatOnChainActionAttributionMessage(targetChainId, agentSolanaPubkey) {
|
|
476
|
+
const caip2 = targetChainId.trim();
|
|
477
|
+
const agent = agentSolanaPubkey.trim();
|
|
478
|
+
if (!caip2.includes(":") || !agent) {
|
|
479
|
+
throw new SwarmClientError({
|
|
480
|
+
code: "INVALID_ARGUMENT",
|
|
481
|
+
operation: "shillbot.formatOnChainActionAttributionMessage",
|
|
482
|
+
message: "targetChainId (CAIP-2) and agentSolanaPubkey are required",
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
return `swarm-attr-v1:${caip2}:${agent}`;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Build a canonical `content_id` proof reference for `PlatformType::OnChainAction = 11`:
|
|
489
|
+
* `<caip2>:<tx_id>:<index>[:sig:<base64url_nopad_65B>]`.
|
|
490
|
+
*/
|
|
491
|
+
export function buildOnChainActionProofRef(params) {
|
|
492
|
+
const caip2 = params.targetChainId.trim();
|
|
493
|
+
const txId = params.txId.trim();
|
|
494
|
+
if (!caip2.includes(":") || !txId) {
|
|
495
|
+
throw new SwarmClientError({
|
|
496
|
+
code: "INVALID_ARGUMENT",
|
|
497
|
+
operation: "shillbot.buildOnChainActionProofRef",
|
|
498
|
+
message: "targetChainId and txId are required",
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
if (!Number.isInteger(params.index) || params.index < 0) {
|
|
502
|
+
throw new SwarmClientError({
|
|
503
|
+
code: "INVALID_ARGUMENT",
|
|
504
|
+
operation: "shillbot.buildOnChainActionProofRef",
|
|
505
|
+
message: "index must be a non-negative integer",
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
const normalizedTxId = caip2.startsWith("eip155:") ? txId.toLowerCase() : txId;
|
|
509
|
+
if (params.attributionSignature === undefined) {
|
|
510
|
+
return `${caip2}:${normalizedTxId}:${params.index}`;
|
|
511
|
+
}
|
|
512
|
+
let sigBytes;
|
|
513
|
+
if (typeof params.attributionSignature === "string") {
|
|
514
|
+
const hex = params.attributionSignature.trim().replace(/^0x/i, "");
|
|
515
|
+
if (!/^[0-9a-fA-F]{130}$/.test(hex)) {
|
|
516
|
+
throw new SwarmClientError({
|
|
517
|
+
code: "INVALID_ARGUMENT",
|
|
518
|
+
operation: "shillbot.buildOnChainActionProofRef",
|
|
519
|
+
message: "attributionSignature hex must be 65 bytes (130 hex chars)",
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
sigBytes = Buffer.from(hex, "hex");
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
sigBytes = Buffer.from(params.attributionSignature);
|
|
526
|
+
}
|
|
527
|
+
if (sigBytes.length !== 65) {
|
|
528
|
+
throw new SwarmClientError({
|
|
529
|
+
code: "INVALID_ARGUMENT",
|
|
530
|
+
operation: "shillbot.buildOnChainActionProofRef",
|
|
531
|
+
message: `attributionSignature must be 65 bytes, got ${sigBytes.length}`,
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
const b64url = sigBytes
|
|
535
|
+
.toString("base64")
|
|
536
|
+
.replace(/\+/g, "-")
|
|
537
|
+
.replace(/\//g, "_")
|
|
538
|
+
.replace(/=+$/g, "");
|
|
539
|
+
return `${caip2}:${normalizedTxId}:${params.index}:sig:${b64url}`;
|
|
540
|
+
}
|
|
448
541
|
export async function signBroadcastPreparedTransaction(input) {
|
|
449
542
|
validatePreparedTransaction(input.transaction, input.expected);
|
|
450
543
|
const timeoutMs = input.timeoutMs ?? 60_000;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLIENT_VERSION = "0.
|
|
1
|
+
export declare const CLIENT_VERSION = "0.4.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLIENT_VERSION = "0.
|
|
1
|
+
export const CLIENT_VERSION = "0.4.1";
|