@finchtech/cli 0.2.0 → 0.2.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/dist/finch.js +541 -191
- package/package.json +16 -15
package/dist/finch.js
CHANGED
|
@@ -35826,7 +35826,17 @@ var init_public = __esm({
|
|
|
35826
35826
|
});
|
|
35827
35827
|
|
|
35828
35828
|
// ../../packages/skill-market-contracts/src/deployment.ts
|
|
35829
|
-
|
|
35829
|
+
function skillV3SourceCommit(chainId) {
|
|
35830
|
+
const selected = SKILL_V3_DEPLOYMENTS.find((candidate) => candidate.chainId === chainId);
|
|
35831
|
+
if (selected === void 0) {
|
|
35832
|
+
throw new TypeError(`Skill V3 is not deployed to chain ${chainId} in this environment.`);
|
|
35833
|
+
}
|
|
35834
|
+
return selected.sourceCommit;
|
|
35835
|
+
}
|
|
35836
|
+
function skillV3ChainTag(chainId) {
|
|
35837
|
+
return getSkillDeliveryDeployment(environment2, chainId).chainTag;
|
|
35838
|
+
}
|
|
35839
|
+
var environment2, deployment, delivery, SKILL_V3_DEPLOYMENTS, SKILL_V3_CHAIN_IDS, SKILL_V3_CHAIN_ID, SKILL_V3_SOURCE_COMMIT, SKILL_V3_DEPLOYMENT_BLOCK, SKILL_V3_FACTORY_DEPLOYMENT_BLOCK, SKILL_V3_CHAIN_TAG, SKILL_V3_ADDRESSES;
|
|
35830
35840
|
var init_deployment = __esm({
|
|
35831
35841
|
"../../packages/skill-market-contracts/src/deployment.ts"() {
|
|
35832
35842
|
"use strict";
|
|
@@ -35836,8 +35846,17 @@ var init_deployment = __esm({
|
|
|
35836
35846
|
environment2 = resolveSkillProtocolEnvironment(process.env.FINCH_ENVIRONMENT);
|
|
35837
35847
|
deployment = getSkillProtocolDeployment(environment2);
|
|
35838
35848
|
delivery = getSkillDeliveryDeployment(environment2, deployment.chainId);
|
|
35839
|
-
|
|
35849
|
+
SKILL_V3_DEPLOYMENTS = Object.freeze(
|
|
35850
|
+
getSkillProtocolChainIds(environment2).map((chainId) => {
|
|
35851
|
+
const selected = getSkillProtocolDeployment(environment2, chainId);
|
|
35852
|
+
return Object.freeze({ chainId, sourceCommit: selected.sourceCommit });
|
|
35853
|
+
})
|
|
35854
|
+
);
|
|
35855
|
+
SKILL_V3_CHAIN_IDS = Object.freeze(
|
|
35856
|
+
SKILL_V3_DEPLOYMENTS.map(({ chainId }) => chainId)
|
|
35857
|
+
);
|
|
35840
35858
|
SKILL_V3_CHAIN_ID = deployment.chainId;
|
|
35859
|
+
SKILL_V3_SOURCE_COMMIT = skillV3SourceCommit(SKILL_V3_CHAIN_ID);
|
|
35841
35860
|
SKILL_V3_DEPLOYMENT_BLOCK = BigInt(deployment.deploymentBlock);
|
|
35842
35861
|
SKILL_V3_FACTORY_DEPLOYMENT_BLOCK = BigInt(deployment.factoryDeploymentBlock);
|
|
35843
35862
|
SKILL_V3_CHAIN_TAG = delivery.chainTag;
|
|
@@ -35849,18 +35868,27 @@ var init_deployment = __esm({
|
|
|
35849
35868
|
skillMarket: deployment.skillMarketAddress,
|
|
35850
35869
|
feeRouter: deployment.feeRouterAddress
|
|
35851
35870
|
});
|
|
35852
|
-
SKILL_V3_CHAIN_IDS = getSkillProtocolChainIds(environment2);
|
|
35853
35871
|
}
|
|
35854
35872
|
});
|
|
35855
35873
|
|
|
35856
35874
|
// ../../packages/skill-market-contracts/src/schemas.ts
|
|
35875
|
+
function authorityVariants(properties) {
|
|
35876
|
+
return Object.freeze(SKILL_V3_DEPLOYMENTS.map(({ chainId, sourceCommit }) => strictObjectSchema3({
|
|
35877
|
+
...properties,
|
|
35878
|
+
sourceCommit: { const: sourceCommit },
|
|
35879
|
+
chainId: { const: chainId }
|
|
35880
|
+
})));
|
|
35881
|
+
}
|
|
35882
|
+
function authorityObjectSchema(properties) {
|
|
35883
|
+
return Object.freeze({ oneOf: authorityVariants(properties) });
|
|
35884
|
+
}
|
|
35857
35885
|
function skillIntentConfirmationIdempotencyKey(chainId, transactionHash3) {
|
|
35858
|
-
if (chainId
|
|
35886
|
+
if (!SKILL_V3_CHAIN_IDS.includes(chainId) || !/^0x[0-9a-f]{64}$/u.test(transactionHash3)) {
|
|
35859
35887
|
throw new TypeError("Skill confirmation identity is invalid.");
|
|
35860
35888
|
}
|
|
35861
35889
|
return `skill-intent-confirm:${chainId}:${transactionHash3}`;
|
|
35862
35890
|
}
|
|
35863
|
-
var versionSchema, skillCategorySchema, nullableSkillCategorySchema, skillSigningAuthoritySchema, skillSourceKindSchema, skillContentModeSchema, skillListRequestSchema, skillDetailRequestSchema, skillDeliveryRequestSchema, skillPurchaseIntentRequestSchema, skillConvertIntentRequestSchema, skillPublicationPrepareRequestFields, skillPublicationPrepareRequestSchema, skillVersionPrepareRequestSchema, skillSetUnitPriceIntentRequestSchema, skillSetMaxSupplyIntentRequestSchema, skillDisplayCategoryUpdateRequestSchema, skillDisplayCategoryResponseSchema, sellStatusSchema, skillProjectionSchema, skillSearchProjectionSchema, skillListResponseSchema, skillLitDataSchema, skillDeliveryFields, skillDeliveryResponseSchema, intentResponseFields,
|
|
35891
|
+
var versionSchema, skillChainIdSchema, skillCategorySchema, nullableSkillCategorySchema, skillSigningAuthoritySchema, skillSourceKindSchema, skillContentModeSchema, skillListRequestSchema, skillDetailRequestSchema, skillDeliveryRequestSchema, skillPurchaseIntentRequestSchema, skillConvertIntentRequestSchema, skillPublicationPrepareRequestFields, skillPublicationPrepareRequestSchema, skillVersionPrepareRequestSchema, skillSetUnitPriceIntentRequestSchema, skillSetMaxSupplyIntentRequestSchema, skillDisplayCategoryUpdateRequestSchema, skillDisplayCategoryResponseSchema, sellStatusSchema, skillProjectionSchema, skillSearchProjectionSchema, skillListResponseSchema, skillLitDataSchema, skillDeliveryFields, skillDeliveryResponseSchema, intentResponseFields, skillBuyerIntentResponseVariants, skillSetUnitPriceIntentResponseVariants, skillSetMaxSupplyIntentResponseVariants, skillIntentResponseSchema, publishLocalActionSchema, versionLocalActionSchema, skillPublicationPrepareResponseSchema, skillVersionPrepareResponseSchema, nullableText, boundedTextList, skillPresentationSchema, skillDetailResponseSchema, skillManageRequestSchema, skillManageResponseSchema, skillPresentationPrepareRequestSchema, skillPresentationPrepareResponseSchema, skillAssetPrepareRequestSchema, skillAssetPrepareResponseSchema, skillIntentConfirmRequestSchema, skillIntentConfirmResponseSchema, skillErrorEnvelopeSchema;
|
|
35864
35892
|
var init_schemas4 = __esm({
|
|
35865
35893
|
"../../packages/skill-market-contracts/src/schemas.ts"() {
|
|
35866
35894
|
"use strict";
|
|
@@ -35869,6 +35897,7 @@ var init_schemas4 = __esm({
|
|
|
35869
35897
|
init_public();
|
|
35870
35898
|
init_public();
|
|
35871
35899
|
versionSchema = { type: "integer", minimum: 1, maximum: 4294967295 };
|
|
35900
|
+
skillChainIdSchema = { type: "integer", enum: SKILL_V3_CHAIN_IDS };
|
|
35872
35901
|
skillCategorySchema = { type: "string", enum: SKILL_CATEGORIES };
|
|
35873
35902
|
nullableSkillCategorySchema = { type: ["string", "null"], enum: [...SKILL_CATEGORIES, null] };
|
|
35874
35903
|
skillSigningAuthoritySchema = strictObjectSchema3({
|
|
@@ -35892,25 +35921,30 @@ var init_schemas4 = __esm({
|
|
|
35892
35921
|
cursor: { type: "string", minLength: 1, maxLength: 512, pattern: "^[A-Za-z0-9_-]+$" }
|
|
35893
35922
|
}, []);
|
|
35894
35923
|
skillDetailRequestSchema = strictObjectSchema3({
|
|
35924
|
+
chainId: skillChainIdSchema,
|
|
35895
35925
|
skillId: positiveIntegerStringSchema2,
|
|
35896
35926
|
version: versionSchema
|
|
35897
|
-
}, ["skillId"]);
|
|
35927
|
+
}, ["chainId", "skillId"]);
|
|
35898
35928
|
skillDeliveryRequestSchema = strictObjectSchema3({
|
|
35929
|
+
chainId: skillChainIdSchema,
|
|
35899
35930
|
skillId: positiveIntegerStringSchema2,
|
|
35900
35931
|
version: versionSchema
|
|
35901
35932
|
});
|
|
35902
35933
|
skillPurchaseIntentRequestSchema = strictObjectSchema3({
|
|
35934
|
+
chainId: skillChainIdSchema,
|
|
35903
35935
|
skillId: positiveIntegerStringSchema2,
|
|
35904
35936
|
version: versionSchema,
|
|
35905
35937
|
quantity: positiveIntegerStringSchema2
|
|
35906
35938
|
});
|
|
35907
35939
|
skillConvertIntentRequestSchema = strictObjectSchema3({
|
|
35940
|
+
chainId: skillChainIdSchema,
|
|
35908
35941
|
skillId: positiveIntegerStringSchema2,
|
|
35909
35942
|
fromVersion: versionSchema,
|
|
35910
35943
|
toVersion: versionSchema,
|
|
35911
35944
|
quantity: positiveIntegerStringSchema2
|
|
35912
35945
|
});
|
|
35913
35946
|
skillPublicationPrepareRequestFields = {
|
|
35947
|
+
chainId: skillChainIdSchema,
|
|
35914
35948
|
slug: { type: "string", minLength: 9, maxLength: 200, pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*_finchip$" },
|
|
35915
35949
|
name: { type: "string", minLength: 1, maxLength: 200 },
|
|
35916
35950
|
category: skillCategorySchema,
|
|
@@ -35925,23 +35959,28 @@ var init_schemas4 = __esm({
|
|
|
35925
35959
|
};
|
|
35926
35960
|
skillPublicationPrepareRequestSchema = strictObjectSchema3(skillPublicationPrepareRequestFields);
|
|
35927
35961
|
skillVersionPrepareRequestSchema = strictObjectSchema3({
|
|
35962
|
+
chainId: skillChainIdSchema,
|
|
35928
35963
|
skillId: positiveIntegerStringSchema2,
|
|
35929
35964
|
sourceKind: skillSourceKindSchema,
|
|
35930
35965
|
contentMode: skillContentModeSchema
|
|
35931
35966
|
});
|
|
35932
35967
|
skillSetUnitPriceIntentRequestSchema = strictObjectSchema3({
|
|
35968
|
+
chainId: skillChainIdSchema,
|
|
35933
35969
|
skillId: positiveIntegerStringSchema2,
|
|
35934
35970
|
unitPrice: unsignedIntegerStringSchema
|
|
35935
35971
|
});
|
|
35936
35972
|
skillSetMaxSupplyIntentRequestSchema = strictObjectSchema3({
|
|
35973
|
+
chainId: skillChainIdSchema,
|
|
35937
35974
|
skillId: positiveIntegerStringSchema2,
|
|
35938
35975
|
maxSupply: unsignedIntegerStringSchema
|
|
35939
35976
|
});
|
|
35940
35977
|
skillDisplayCategoryUpdateRequestSchema = strictObjectSchema3({
|
|
35978
|
+
chainId: skillChainIdSchema,
|
|
35941
35979
|
skillId: positiveIntegerStringSchema2,
|
|
35942
35980
|
displayCategory: nullableSkillCategorySchema
|
|
35943
35981
|
});
|
|
35944
35982
|
skillDisplayCategoryResponseSchema = strictObjectSchema3({
|
|
35983
|
+
chainId: skillChainIdSchema,
|
|
35945
35984
|
skillId: positiveIntegerStringSchema2,
|
|
35946
35985
|
declaredCategory: { type: "string", minLength: 1, maxLength: 100 },
|
|
35947
35986
|
displayCategory: { type: ["string", "null"], minLength: 1, maxLength: 100 },
|
|
@@ -35954,7 +35993,7 @@ var init_schemas4 = __esm({
|
|
|
35954
35993
|
supplyAvailable: { type: "boolean" }
|
|
35955
35994
|
});
|
|
35956
35995
|
skillProjectionSchema = strictObjectSchema3({
|
|
35957
|
-
chainId:
|
|
35996
|
+
chainId: skillChainIdSchema,
|
|
35958
35997
|
skillId: positiveIntegerStringSchema2,
|
|
35959
35998
|
slug: { type: "string" },
|
|
35960
35999
|
name: { type: "string" },
|
|
@@ -35978,7 +36017,7 @@ var init_schemas4 = __esm({
|
|
|
35978
36017
|
sellStatus: sellStatusSchema
|
|
35979
36018
|
});
|
|
35980
36019
|
skillSearchProjectionSchema = strictObjectSchema3({
|
|
35981
|
-
chainId:
|
|
36020
|
+
chainId: skillChainIdSchema,
|
|
35982
36021
|
skillId: positiveIntegerStringSchema2,
|
|
35983
36022
|
slug: { type: "string" },
|
|
35984
36023
|
name: { type: "string" },
|
|
@@ -36013,7 +36052,7 @@ var init_schemas4 = __esm({
|
|
|
36013
36052
|
chain: { type: "string", minLength: 1, maxLength: 100 }
|
|
36014
36053
|
});
|
|
36015
36054
|
skillDeliveryFields = {
|
|
36016
|
-
chainId:
|
|
36055
|
+
chainId: skillChainIdSchema,
|
|
36017
36056
|
skillId: positiveIntegerStringSchema2,
|
|
36018
36057
|
version: versionSchema,
|
|
36019
36058
|
packageURI: { type: "string", minLength: 1, maxLength: 2e3 },
|
|
@@ -36024,28 +36063,26 @@ var init_schemas4 = __esm({
|
|
|
36024
36063
|
strictObjectSchema3({ ...skillDeliveryFields, entitledWallet: addressSchema2, plaintext: { const: false }, litData: skillLitDataSchema })
|
|
36025
36064
|
] });
|
|
36026
36065
|
intentResponseFields = {
|
|
36027
|
-
sourceCommit: { const: SKILL_V3_SOURCE_COMMIT },
|
|
36028
|
-
chainId: { const: SKILL_V3_CHAIN_ID },
|
|
36029
36066
|
to: addressSchema2,
|
|
36030
36067
|
data: { type: "string", pattern: "^0x(?:[0-9a-fA-F]{2})+$" },
|
|
36031
36068
|
value: unsignedIntegerStringSchema,
|
|
36032
36069
|
summary: { type: "string", minLength: 1, maxLength: 500 }
|
|
36033
36070
|
};
|
|
36034
|
-
|
|
36071
|
+
skillBuyerIntentResponseVariants = authorityVariants({
|
|
36035
36072
|
kind: { type: "string", enum: ["purchase", "convert"] },
|
|
36036
36073
|
...intentResponseFields,
|
|
36037
36074
|
walletAddress: addressSchema2,
|
|
36038
36075
|
request: openObjectSchema2,
|
|
36039
36076
|
signingAuthority: skillSigningAuthoritySchema
|
|
36040
36077
|
});
|
|
36041
|
-
|
|
36078
|
+
skillSetUnitPriceIntentResponseVariants = authorityVariants({
|
|
36042
36079
|
kind: { const: "set_unit_price" },
|
|
36043
36080
|
...intentResponseFields,
|
|
36044
36081
|
walletAddress: addressSchema2,
|
|
36045
36082
|
request: skillSetUnitPriceIntentRequestSchema,
|
|
36046
36083
|
signingAuthority: skillSigningAuthoritySchema
|
|
36047
36084
|
});
|
|
36048
|
-
|
|
36085
|
+
skillSetMaxSupplyIntentResponseVariants = authorityVariants({
|
|
36049
36086
|
kind: { const: "set_max_supply" },
|
|
36050
36087
|
...intentResponseFields,
|
|
36051
36088
|
walletAddress: addressSchema2,
|
|
@@ -36053,9 +36090,9 @@ var init_schemas4 = __esm({
|
|
|
36053
36090
|
signingAuthority: skillSigningAuthoritySchema
|
|
36054
36091
|
});
|
|
36055
36092
|
skillIntentResponseSchema = Object.freeze({ oneOf: [
|
|
36056
|
-
|
|
36057
|
-
|
|
36058
|
-
|
|
36093
|
+
...skillBuyerIntentResponseVariants,
|
|
36094
|
+
...skillSetUnitPriceIntentResponseVariants,
|
|
36095
|
+
...skillSetMaxSupplyIntentResponseVariants
|
|
36059
36096
|
] });
|
|
36060
36097
|
publishLocalActionSchema = strictObjectSchema3({
|
|
36061
36098
|
client: { const: "finch" },
|
|
@@ -36066,10 +36103,8 @@ var init_schemas4 = __esm({
|
|
|
36066
36103
|
command: { const: "skill version-submit" },
|
|
36067
36104
|
arguments: strictObjectSchema3({ skillId: positiveIntegerStringSchema2 })
|
|
36068
36105
|
});
|
|
36069
|
-
skillPublicationPrepareResponseSchema =
|
|
36106
|
+
skillPublicationPrepareResponseSchema = authorityObjectSchema({
|
|
36070
36107
|
kind: { const: "publish" },
|
|
36071
|
-
sourceCommit: { const: SKILL_V3_SOURCE_COMMIT },
|
|
36072
|
-
chainId: { const: SKILL_V3_CHAIN_ID },
|
|
36073
36108
|
walletAddress: addressSchema2,
|
|
36074
36109
|
signingAuthority: skillSigningAuthoritySchema,
|
|
36075
36110
|
request: strictObjectSchema3({
|
|
@@ -36077,10 +36112,8 @@ var init_schemas4 = __esm({
|
|
|
36077
36112
|
}),
|
|
36078
36113
|
localAction: publishLocalActionSchema
|
|
36079
36114
|
});
|
|
36080
|
-
skillVersionPrepareResponseSchema =
|
|
36115
|
+
skillVersionPrepareResponseSchema = authorityObjectSchema({
|
|
36081
36116
|
kind: { const: "version" },
|
|
36082
|
-
sourceCommit: { const: SKILL_V3_SOURCE_COMMIT },
|
|
36083
|
-
chainId: { const: SKILL_V3_CHAIN_ID },
|
|
36084
36117
|
walletAddress: addressSchema2,
|
|
36085
36118
|
signingAuthority: skillSigningAuthoritySchema,
|
|
36086
36119
|
skillId: positiveIntegerStringSchema2,
|
|
@@ -36140,7 +36173,10 @@ var init_schemas4 = __esm({
|
|
|
36140
36173
|
...skillProjectionSchema.properties,
|
|
36141
36174
|
presentation: { oneOf: [{ type: "null" }, skillPresentationSchema] }
|
|
36142
36175
|
});
|
|
36143
|
-
skillManageRequestSchema = strictObjectSchema3({
|
|
36176
|
+
skillManageRequestSchema = strictObjectSchema3({
|
|
36177
|
+
chainId: skillChainIdSchema,
|
|
36178
|
+
skillId: positiveIntegerStringSchema2
|
|
36179
|
+
});
|
|
36144
36180
|
skillManageResponseSchema = strictObjectSchema3({
|
|
36145
36181
|
skill: skillProjectionSchema,
|
|
36146
36182
|
contentMode: skillContentModeSchema,
|
|
@@ -36148,13 +36184,12 @@ var init_schemas4 = __esm({
|
|
|
36148
36184
|
presentation: { oneOf: [{ type: "null" }, skillPresentationSchema] }
|
|
36149
36185
|
});
|
|
36150
36186
|
skillPresentationPrepareRequestSchema = strictObjectSchema3({
|
|
36187
|
+
chainId: skillChainIdSchema,
|
|
36151
36188
|
skillId: positiveIntegerStringSchema2,
|
|
36152
36189
|
presentation: skillPresentationSchema
|
|
36153
36190
|
});
|
|
36154
|
-
skillPresentationPrepareResponseSchema =
|
|
36191
|
+
skillPresentationPrepareResponseSchema = authorityObjectSchema({
|
|
36155
36192
|
kind: { const: "presentation" },
|
|
36156
|
-
sourceCommit: { const: SKILL_V3_SOURCE_COMMIT },
|
|
36157
|
-
chainId: { const: SKILL_V3_CHAIN_ID },
|
|
36158
36193
|
walletAddress: addressSchema2,
|
|
36159
36194
|
signingAuthority: skillSigningAuthoritySchema,
|
|
36160
36195
|
skillId: positiveIntegerStringSchema2,
|
|
@@ -36168,13 +36203,12 @@ var init_schemas4 = __esm({
|
|
|
36168
36203
|
})
|
|
36169
36204
|
});
|
|
36170
36205
|
skillAssetPrepareRequestSchema = strictObjectSchema3({
|
|
36206
|
+
chainId: skillChainIdSchema,
|
|
36171
36207
|
skillId: positiveIntegerStringSchema2,
|
|
36172
36208
|
assetKind: { const: "cover" }
|
|
36173
36209
|
});
|
|
36174
|
-
skillAssetPrepareResponseSchema =
|
|
36210
|
+
skillAssetPrepareResponseSchema = authorityObjectSchema({
|
|
36175
36211
|
kind: { const: "asset_upload" },
|
|
36176
|
-
sourceCommit: { const: SKILL_V3_SOURCE_COMMIT },
|
|
36177
|
-
chainId: { const: SKILL_V3_CHAIN_ID },
|
|
36178
36212
|
walletAddress: addressSchema2,
|
|
36179
36213
|
skillId: positiveIntegerStringSchema2,
|
|
36180
36214
|
assetKind: { const: "cover" },
|
|
@@ -36193,14 +36227,18 @@ var init_schemas4 = __esm({
|
|
|
36193
36227
|
})
|
|
36194
36228
|
});
|
|
36195
36229
|
skillIntentConfirmRequestSchema = strictObjectSchema3({
|
|
36196
|
-
chainId:
|
|
36230
|
+
chainId: skillChainIdSchema,
|
|
36197
36231
|
transactionHash: transactionHashSchema2
|
|
36198
36232
|
});
|
|
36199
36233
|
skillIntentConfirmResponseSchema = strictObjectSchema3({
|
|
36200
36234
|
status: { type: "string", enum: ["projected", "indexing_pending"] }
|
|
36201
36235
|
});
|
|
36202
36236
|
skillErrorEnvelopeSchema = strictObjectSchema3({
|
|
36203
|
-
error: strictObjectSchema3({
|
|
36237
|
+
error: strictObjectSchema3({
|
|
36238
|
+
code: { type: "string" },
|
|
36239
|
+
message: { type: "string" },
|
|
36240
|
+
traceId: { type: "string", minLength: 1, maxLength: 128, pattern: "^[A-Za-z0-9_-]+$" }
|
|
36241
|
+
})
|
|
36204
36242
|
});
|
|
36205
36243
|
}
|
|
36206
36244
|
});
|
|
@@ -36388,6 +36426,20 @@ function parseRemoteError(response, value) {
|
|
|
36388
36426
|
}
|
|
36389
36427
|
return envelope;
|
|
36390
36428
|
}
|
|
36429
|
+
function parseSkillRemoteError(value) {
|
|
36430
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Skill error envelope is invalid.");
|
|
36431
|
+
const error51 = value.error;
|
|
36432
|
+
if (error51 === null || typeof error51 !== "object" || Array.isArray(error51)) throw new TypeError("Skill error envelope is invalid.");
|
|
36433
|
+
const candidate = error51;
|
|
36434
|
+
if (typeof candidate.code !== "string" || candidate.code.length < 1 || typeof candidate.message !== "string" || candidate.message.length < 1 || candidate.traceId !== void 0 && (typeof candidate.traceId !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u.test(candidate.traceId))) {
|
|
36435
|
+
throw new TypeError("Skill error envelope is invalid.");
|
|
36436
|
+
}
|
|
36437
|
+
return Object.freeze({ error: Object.freeze({
|
|
36438
|
+
code: candidate.code,
|
|
36439
|
+
message: candidate.message,
|
|
36440
|
+
...candidate.traceId === void 0 ? {} : { traceId: candidate.traceId }
|
|
36441
|
+
}) });
|
|
36442
|
+
}
|
|
36391
36443
|
var import_ajv, CLI_MERCHANT_OPERATION_IDS, CliHttpError, ajv, validatorCache, oauthAuthorizationResponseSchema, oauthErrorResponseSchema, AgentCliHttpClient;
|
|
36392
36444
|
var init_api2 = __esm({
|
|
36393
36445
|
"src/api.ts"() {
|
|
@@ -36524,8 +36576,13 @@ var init_api2 = __esm({
|
|
|
36524
36576
|
throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", null, { cause });
|
|
36525
36577
|
}
|
|
36526
36578
|
if (response.status !== expectedStatus) {
|
|
36527
|
-
|
|
36528
|
-
|
|
36579
|
+
try {
|
|
36580
|
+
const envelope = parseSkillRemoteError(await readBoundedJson(response));
|
|
36581
|
+
throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", response.status, { envelope });
|
|
36582
|
+
} catch (cause) {
|
|
36583
|
+
if (cause instanceof CliHttpError) throw cause;
|
|
36584
|
+
throw new CliHttpError("CLI_RESPONSE_INVALID", response.status, { cause });
|
|
36585
|
+
}
|
|
36529
36586
|
}
|
|
36530
36587
|
return response;
|
|
36531
36588
|
}
|
|
@@ -36620,10 +36677,10 @@ var init_api2 = __esm({
|
|
|
36620
36677
|
body: JSON.stringify(body)
|
|
36621
36678
|
}));
|
|
36622
36679
|
}
|
|
36623
|
-
async resolveSkillId(slug, bearer) {
|
|
36680
|
+
async resolveSkillId(chainId, slug, bearer) {
|
|
36624
36681
|
let response;
|
|
36625
36682
|
try {
|
|
36626
|
-
response = await this.fetchImplementation(`${this.origin}/api/skills/resolve?${new URLSearchParams({ slug })}`, {
|
|
36683
|
+
response = await this.fetchImplementation(`${this.origin}/api/skills/resolve?${new URLSearchParams({ chainId: String(chainId), slug })}`, {
|
|
36627
36684
|
method: "GET",
|
|
36628
36685
|
headers: { authorization: `Bearer ${bearer}` },
|
|
36629
36686
|
redirect: "error",
|
|
@@ -36637,15 +36694,20 @@ var init_api2 = __esm({
|
|
|
36637
36694
|
return null;
|
|
36638
36695
|
}
|
|
36639
36696
|
if (response.status !== 200) {
|
|
36640
|
-
|
|
36641
|
-
|
|
36697
|
+
try {
|
|
36698
|
+
const envelope = parseSkillRemoteError(await readBoundedJson(response));
|
|
36699
|
+
throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", response.status, { envelope });
|
|
36700
|
+
} catch (cause) {
|
|
36701
|
+
if (cause instanceof CliHttpError) throw cause;
|
|
36702
|
+
throw new CliHttpError("CLI_RESPONSE_INVALID", response.status, { cause });
|
|
36703
|
+
}
|
|
36642
36704
|
}
|
|
36643
36705
|
const body = await readBoundedJson(response);
|
|
36644
36706
|
if (typeof body?.skillId !== "string" || !/^[1-9][0-9]*$/u.test(body.skillId)) throw new CliHttpError("CLI_RESPONSE_INVALID", 200);
|
|
36645
36707
|
return body.skillId;
|
|
36646
36708
|
}
|
|
36647
|
-
async readSkillCurrentVersion(skillId, bearer) {
|
|
36648
|
-
const response = await this.skillFetch(`/api/skills/resolve?${new URLSearchParams({ skillId })}`, {
|
|
36709
|
+
async readSkillCurrentVersion(chainId, skillId, bearer) {
|
|
36710
|
+
const response = await this.skillFetch(`/api/skills/resolve?${new URLSearchParams({ chainId: String(chainId), skillId })}`, {
|
|
36649
36711
|
method: "GET",
|
|
36650
36712
|
headers: { authorization: `Bearer ${bearer}` },
|
|
36651
36713
|
cache: "no-store"
|
|
@@ -36658,7 +36720,7 @@ var init_api2 = __esm({
|
|
|
36658
36720
|
const response = await this.skillFetch("/api/skills/content-key", {
|
|
36659
36721
|
method: "POST",
|
|
36660
36722
|
headers: { authorization: `Bearer ${input.bearer}`, "content-type": "application/json" },
|
|
36661
|
-
body: JSON.stringify({ skillId: input.skillId, version: input.version, wallet: input.wallet, message: input.message, signature: input.signature })
|
|
36723
|
+
body: JSON.stringify({ chainId: input.chainId, skillId: input.skillId, version: input.version, wallet: input.wallet, message: input.message, signature: input.signature })
|
|
36662
36724
|
});
|
|
36663
36725
|
const body = await readBoundedJson(response);
|
|
36664
36726
|
if (body.scheme === "FINCHIP_V2" && typeof body.key === "string" && /^0x[0-9a-fA-F]{64}$/u.test(body.key) && body.contentKey === null) return Object.freeze({ scheme: body.scheme, key: body.key, contentKey: null });
|
|
@@ -36675,6 +36737,7 @@ var init_api2 = __esm({
|
|
|
36675
36737
|
"content-type": "application/json"
|
|
36676
36738
|
},
|
|
36677
36739
|
body: JSON.stringify({
|
|
36740
|
+
chainId: input.chainId,
|
|
36678
36741
|
skillId: input.skillId,
|
|
36679
36742
|
version: input.version,
|
|
36680
36743
|
contentKey: input.contentKey
|
|
@@ -36694,24 +36757,36 @@ var init_api2 = __esm({
|
|
|
36694
36757
|
});
|
|
36695
36758
|
return readBoundedBytes(response, 1, 10 * 1024 * 1024);
|
|
36696
36759
|
}
|
|
36697
|
-
async confirmSkillProjection(transactionHash3, bearer) {
|
|
36760
|
+
async confirmSkillProjection(chainId, transactionHash3, bearer) {
|
|
36698
36761
|
let response;
|
|
36699
36762
|
try {
|
|
36700
36763
|
response = await this.fetchImplementation(`${this.origin}/api/skills/projection`, {
|
|
36701
36764
|
method: "POST",
|
|
36702
36765
|
redirect: "error",
|
|
36703
36766
|
headers: { authorization: `Bearer ${bearer}`, "content-type": "application/json" },
|
|
36704
|
-
body: JSON.stringify({ transactionHash: transactionHash3 })
|
|
36767
|
+
body: JSON.stringify({ chainId, transactionHash: transactionHash3 })
|
|
36705
36768
|
});
|
|
36706
36769
|
} catch {
|
|
36707
36770
|
return "indexing_pending";
|
|
36708
36771
|
}
|
|
36709
36772
|
if (response.status !== 200 && response.status !== 202) {
|
|
36710
|
-
|
|
36711
|
-
|
|
36773
|
+
try {
|
|
36774
|
+
const envelope = parseSkillRemoteError(await readBoundedJson(response));
|
|
36775
|
+
throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", response.status, { envelope });
|
|
36776
|
+
} catch (cause) {
|
|
36777
|
+
if (cause instanceof CliHttpError) throw cause;
|
|
36778
|
+
throw new CliHttpError("CLI_RESPONSE_INVALID", response.status, { cause });
|
|
36779
|
+
}
|
|
36712
36780
|
}
|
|
36713
|
-
|
|
36714
|
-
|
|
36781
|
+
let body;
|
|
36782
|
+
try {
|
|
36783
|
+
body = await readBoundedJson(response);
|
|
36784
|
+
} catch (cause) {
|
|
36785
|
+
throw new CliHttpError("CLI_RESPONSE_INVALID", response.status, { cause });
|
|
36786
|
+
}
|
|
36787
|
+
if (response.status === 200 && body?.status === "projected") return "projected";
|
|
36788
|
+
if (response.status === 202 && body?.status === "indexing_pending") return "indexing_pending";
|
|
36789
|
+
throw new CliHttpError("CLI_RESPONSE_INVALID", response.status);
|
|
36715
36790
|
}
|
|
36716
36791
|
getSession(bearer) {
|
|
36717
36792
|
const operation4 = IDENTITY_V1_OPERATIONS.session;
|
|
@@ -37655,6 +37730,11 @@ function integer2(value, name, minimum = 1) {
|
|
|
37655
37730
|
if (!Number.isInteger(value) || Number(value) < minimum || Number(value) > 4294967295) throw new TypeError(`${name} is invalid.`);
|
|
37656
37731
|
return Number(value);
|
|
37657
37732
|
}
|
|
37733
|
+
function skillChain(value, name = "Skill chain") {
|
|
37734
|
+
const chainId = integer2(value, name);
|
|
37735
|
+
if (!SKILL_V3_CHAIN_IDS.includes(chainId)) throw new TypeError(`${name} is not deployed in this environment.`);
|
|
37736
|
+
return chainId;
|
|
37737
|
+
}
|
|
37658
37738
|
function deliveryPackageUri(value) {
|
|
37659
37739
|
return string4(value, "Skill package URI", IPFS);
|
|
37660
37740
|
}
|
|
@@ -37678,10 +37758,12 @@ function assertPublicationAuthority(authority, context) {
|
|
|
37678
37758
|
return authority;
|
|
37679
37759
|
}
|
|
37680
37760
|
function assertAuthority(plan, kind, walletAddress2, requiresSigning = true) {
|
|
37681
|
-
|
|
37682
|
-
|
|
37761
|
+
const chainId = skillChain(plan.chainId);
|
|
37762
|
+
if (plan.kind !== kind || plan.sourceCommit !== skillV3SourceCommit(chainId) || typeof plan.walletAddress !== "string" || plan.walletAddress.toLowerCase() !== walletAddress2.toLowerCase()) {
|
|
37763
|
+
throw new TypeError("Skill local-action authority does not match the active wallet and deployment.");
|
|
37683
37764
|
}
|
|
37684
37765
|
if (requiresSigning) signingAuthority(plan.signingAuthority, walletAddress2);
|
|
37766
|
+
return chainId;
|
|
37685
37767
|
}
|
|
37686
37768
|
function assertLocalAction(value, command, skillId) {
|
|
37687
37769
|
const action = object4(value, "Skill local action");
|
|
@@ -37696,9 +37778,9 @@ function assertLocalAction(value, command, skillId) {
|
|
|
37696
37778
|
function intent(value, walletAddress2) {
|
|
37697
37779
|
const parsed = object4(value, "Skill intent");
|
|
37698
37780
|
exact(parsed, ["chainId", "to", "data", "value", "summary", "signingAuthority"], "Skill intent");
|
|
37699
|
-
|
|
37781
|
+
const chainId = skillChain(parsed.chainId, "Skill intent chain");
|
|
37700
37782
|
return Object.freeze({
|
|
37701
|
-
chainId
|
|
37783
|
+
chainId,
|
|
37702
37784
|
to: string4(parsed.to, "Skill intent target", /^0x[0-9a-fA-F]{40}$/u),
|
|
37703
37785
|
data: string4(parsed.data, "Skill intent calldata", /^0x(?:[0-9a-fA-F]{2})+$/u),
|
|
37704
37786
|
value: string4(parsed.value, "Skill intent value", DECIMAL),
|
|
@@ -37706,6 +37788,11 @@ function intent(value, walletAddress2) {
|
|
|
37706
37788
|
signingAuthority: signingAuthority(parsed.signingAuthority, walletAddress2)
|
|
37707
37789
|
});
|
|
37708
37790
|
}
|
|
37791
|
+
function legacyIntent(value, walletAddress2, authority) {
|
|
37792
|
+
const prepared = object4(value, "Skill legacy intent");
|
|
37793
|
+
exact(prepared, ["chainId", "to", "data", "value", "summary"], "Skill legacy intent");
|
|
37794
|
+
return intent({ ...prepared, signingAuthority: authority }, walletAddress2);
|
|
37795
|
+
}
|
|
37709
37796
|
async function readPublishablePath(inputPath) {
|
|
37710
37797
|
const root = resolve2(inputPath);
|
|
37711
37798
|
const rootStat = await lstat2(root);
|
|
@@ -37742,10 +37829,11 @@ function contentMode(value) {
|
|
|
37742
37829
|
function publishPlan(value, context) {
|
|
37743
37830
|
const plan = object4(value, "Skill publish plan");
|
|
37744
37831
|
exact(plan, ["kind", "sourceCommit", "chainId", "walletAddress", "signingAuthority", "request", "localAction"], "Skill publish plan");
|
|
37745
|
-
assertAuthority(plan, "publish", context.walletAddress);
|
|
37832
|
+
const chainId = assertAuthority(plan, "publish", context.walletAddress);
|
|
37746
37833
|
assertLocalAction(plan.localAction, "skill publish-submit");
|
|
37747
37834
|
const request = object4(plan.request, "Skill publish request");
|
|
37748
|
-
exact(request, ["slug", "name", "category", "licenseTypeName", "imageURI", "sourceKind", "contentMode", "unitPrice", "maxSupply", "royaltyBPS", "usageLimit"], "Skill publish request");
|
|
37835
|
+
exact(request, ["chainId", "slug", "name", "category", "licenseTypeName", "imageURI", "sourceKind", "contentMode", "unitPrice", "maxSupply", "royaltyBPS", "usageLimit"], "Skill publish request");
|
|
37836
|
+
if (request.chainId !== chainId) throw new TypeError("Skill publish request chain is invalid.");
|
|
37749
37837
|
string4(request.slug, "Skill slug");
|
|
37750
37838
|
string4(request.name, "Skill name");
|
|
37751
37839
|
string4(request.category, "Skill category");
|
|
@@ -37760,6 +37848,7 @@ function publishPlan(value, context) {
|
|
|
37760
37848
|
string4(request.usageLimit, "Skill usageLimit", DECIMAL);
|
|
37761
37849
|
if (!Number.isInteger(request.royaltyBPS) || Number(request.royaltyBPS) < 0 || Number(request.royaltyBPS) > 1e3) throw new TypeError("Skill royaltyBPS is invalid.");
|
|
37762
37850
|
return {
|
|
37851
|
+
chainId,
|
|
37763
37852
|
request,
|
|
37764
37853
|
signingAuthority: assertPublicationAuthority(signingAuthority(plan.signingAuthority, context.walletAddress), context)
|
|
37765
37854
|
};
|
|
@@ -37767,14 +37856,15 @@ function publishPlan(value, context) {
|
|
|
37767
37856
|
function versionPlan(value, context) {
|
|
37768
37857
|
const plan = object4(value, "Skill version plan");
|
|
37769
37858
|
exact(plan, ["kind", "sourceCommit", "chainId", "walletAddress", "signingAuthority", "skillId", "currentVersion", "nextVersion", "currentManifestURI", "sourceKind", "contentMode", "localAction"], "Skill version plan");
|
|
37770
|
-
assertAuthority(plan, "version", context.walletAddress);
|
|
37859
|
+
const chainId = assertAuthority(plan, "version", context.walletAddress);
|
|
37771
37860
|
const skillId = string4(plan.skillId, "Skill id", /^[1-9][0-9]*$/u);
|
|
37772
37861
|
assertLocalAction(plan.localAction, "skill version-submit", skillId);
|
|
37773
|
-
const request = { skillId, sourceKind: sourceKind(plan.sourceKind), contentMode: contentMode(plan.contentMode) };
|
|
37862
|
+
const request = { chainId, skillId, sourceKind: sourceKind(plan.sourceKind), contentMode: contentMode(plan.contentMode) };
|
|
37774
37863
|
const currentVersion = integer2(plan.currentVersion, "Current version");
|
|
37775
37864
|
const nextVersion = integer2(plan.nextVersion, "Next version");
|
|
37776
37865
|
if (nextVersion !== currentVersion + 1) throw new TypeError("Skill version plan does not advance exactly one version.");
|
|
37777
37866
|
return {
|
|
37867
|
+
chainId,
|
|
37778
37868
|
request,
|
|
37779
37869
|
currentVersion,
|
|
37780
37870
|
nextVersion,
|
|
@@ -37787,13 +37877,14 @@ function versionPlan(value, context) {
|
|
|
37787
37877
|
function managePlan(value, walletAddress2, kind) {
|
|
37788
37878
|
const plan = object4(value, `Skill ${kind} plan`);
|
|
37789
37879
|
exact(plan, ["kind", "sourceCommit", "chainId", "to", "data", "value", "summary", "walletAddress", "signingAuthority", "request"], `Skill ${kind} plan`);
|
|
37790
|
-
assertAuthority(plan, kind === "price" ? "set_unit_price" : "set_max_supply", walletAddress2);
|
|
37880
|
+
const chainId = assertAuthority(plan, kind === "price" ? "set_unit_price" : "set_max_supply", walletAddress2);
|
|
37791
37881
|
const request = object4(plan.request, `Skill ${kind} request`);
|
|
37792
37882
|
const field = kind === "price" ? "unitPrice" : "maxSupply";
|
|
37793
|
-
exact(request, ["skillId", field], `Skill ${kind} request`);
|
|
37883
|
+
exact(request, ["chainId", "skillId", field], `Skill ${kind} request`);
|
|
37884
|
+
if (request.chainId !== chainId) throw new TypeError(`Skill ${kind} request chain is invalid.`);
|
|
37794
37885
|
string4(request.skillId, "Skill id", /^[1-9][0-9]*$/u);
|
|
37795
37886
|
string4(request[field], `Skill ${field}`, DECIMAL);
|
|
37796
|
-
return { request, intent: intent({
|
|
37887
|
+
return { chainId, request, intent: intent({
|
|
37797
37888
|
chainId: plan.chainId,
|
|
37798
37889
|
to: plan.to,
|
|
37799
37890
|
data: plan.data,
|
|
@@ -37816,14 +37907,16 @@ function presentationPlan(value, walletAddress2) {
|
|
|
37816
37907
|
"presentation",
|
|
37817
37908
|
"localAction"
|
|
37818
37909
|
], "Skill presentation plan");
|
|
37819
|
-
assertAuthority(plan, "presentation", walletAddress2);
|
|
37910
|
+
const chainId = assertAuthority(plan, "presentation", walletAddress2);
|
|
37820
37911
|
const skillId = string4(plan.skillId, "Skill id", /^[1-9][0-9]*$/u);
|
|
37821
37912
|
assertLocalAction(plan.localAction, "skill presentation-submit", skillId);
|
|
37822
37913
|
return {
|
|
37914
|
+
chainId,
|
|
37823
37915
|
skillId,
|
|
37824
37916
|
currentVersion: integer2(plan.currentVersion, "Current version"),
|
|
37825
37917
|
currentManifestURI: string4(plan.currentManifestURI, "Current manifest URI", IPFS),
|
|
37826
|
-
presentation: buildPresentation(plan.presentation)
|
|
37918
|
+
presentation: buildPresentation(plan.presentation),
|
|
37919
|
+
signingAuthority: signingAuthority(plan.signingAuthority, walletAddress2)
|
|
37827
37920
|
};
|
|
37828
37921
|
}
|
|
37829
37922
|
function assetPlan(value, walletAddress2) {
|
|
@@ -37839,7 +37932,7 @@ function assetPlan(value, walletAddress2) {
|
|
|
37839
37932
|
"maxBytes",
|
|
37840
37933
|
"localAction"
|
|
37841
37934
|
], "Skill asset plan");
|
|
37842
|
-
assertAuthority(plan, "asset_upload", walletAddress2, false);
|
|
37935
|
+
const chainId = assertAuthority(plan, "asset_upload", walletAddress2, false);
|
|
37843
37936
|
const skillId = string4(plan.skillId, "Skill id", /^[1-9][0-9]*$/u);
|
|
37844
37937
|
if (plan.assetKind !== "cover" || plan.maxBytes !== 5242880) throw new TypeError("Skill cover authority is invalid.");
|
|
37845
37938
|
const accepted = plan.acceptedMediaTypes;
|
|
@@ -37853,7 +37946,7 @@ function assetPlan(value, walletAddress2) {
|
|
|
37853
37946
|
if (action.client !== "finch" || action.command !== "skill asset-upload" || args.assetKind !== "cover") {
|
|
37854
37947
|
throw new TypeError("Skill cover local action is invalid.");
|
|
37855
37948
|
}
|
|
37856
|
-
return { skillId, acceptedMediaTypes: accepted, maxBytes: plan.maxBytes };
|
|
37949
|
+
return { chainId, skillId, acceptedMediaTypes: accepted, maxBytes: plan.maxBytes };
|
|
37857
37950
|
}
|
|
37858
37951
|
function coverMediaType(bytes) {
|
|
37859
37952
|
const png = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
@@ -37870,9 +37963,7 @@ function isPlaintextSkillDelivery(value) {
|
|
|
37870
37963
|
function deliveryPlan(value, context) {
|
|
37871
37964
|
const delivery2 = object4(value, "Skill delivery");
|
|
37872
37965
|
exact(delivery2, ["chainId", "skillId", "version", "packageURI", "packageHash", "plaintext", "litData", "entitledWallet"], "Skill delivery");
|
|
37873
|
-
|
|
37874
|
-
throw new TypeError("Skill delivery authority is invalid.");
|
|
37875
|
-
}
|
|
37966
|
+
const chainId = skillChain(delivery2.chainId, "Skill delivery chain");
|
|
37876
37967
|
const skillId = string4(delivery2.skillId, "Skill id", /^[1-9][0-9]*$/u);
|
|
37877
37968
|
const version6 = integer2(delivery2.version, "Skill version");
|
|
37878
37969
|
const packageHash = string4(delivery2.packageHash, "Skill package hash", HASH);
|
|
@@ -37880,16 +37971,16 @@ function deliveryPlan(value, context) {
|
|
|
37880
37971
|
const packageURI = deliveryPackageUri(delivery2.packageURI);
|
|
37881
37972
|
if (delivery2.plaintext) {
|
|
37882
37973
|
if (delivery2.litData !== null || delivery2.entitledWallet !== null) throw new TypeError("Plaintext Skill delivery cannot contain wallet or Lit authority.");
|
|
37883
|
-
return { skillId, version: version6, packageURI, packageHash, plaintext: true, litData: null };
|
|
37974
|
+
return { chainId, skillId, version: version6, packageURI, packageHash, plaintext: true, litData: null };
|
|
37884
37975
|
}
|
|
37885
37976
|
if (context === null || typeof delivery2.entitledWallet !== "string" || !/^0x[0-9a-fA-F]{40}$/u.test(delivery2.entitledWallet) || delivery2.entitledWallet.toLowerCase() !== context.walletAddress.toLowerCase()) {
|
|
37886
|
-
throw new TypeError("Protected Skill delivery is not entitled to the active
|
|
37977
|
+
throw new TypeError("Protected Skill delivery is not entitled to the active wallet.");
|
|
37887
37978
|
}
|
|
37888
37979
|
const litData = object4(delivery2.litData, "Skill Lit data");
|
|
37889
37980
|
exact(litData, ["ciphertext", "scheme", "chain"], "Skill Lit data");
|
|
37890
|
-
if (litData.scheme !== SKILL_V3_ENVELOPE_SCHEME && litData.scheme !== SKILL_V3_LIT_ENVELOPE_SCHEME || litData.chain !==
|
|
37981
|
+
if (litData.scheme !== SKILL_V3_ENVELOPE_SCHEME && litData.scheme !== SKILL_V3_LIT_ENVELOPE_SCHEME || litData.chain !== skillV3ChainTag(chainId)) throw new TypeError("Skill Lit data does not match the source-controlled deployment.");
|
|
37891
37982
|
string4(litData.ciphertext, "Skill Lit ciphertext");
|
|
37892
|
-
return { skillId, version: version6, packageURI, packageHash, plaintext: false, litData };
|
|
37983
|
+
return { chainId, skillId, version: version6, packageURI, packageHash, plaintext: false, litData };
|
|
37893
37984
|
}
|
|
37894
37985
|
function required3(value, name) {
|
|
37895
37986
|
if (value === void 0 || value === null) throw new TypeError(`${name} is unavailable.`);
|
|
@@ -37904,10 +37995,12 @@ function recoveryReceipt(value, name) {
|
|
|
37904
37995
|
blockNumber: receipt.blockNumber === null ? null : string4(receipt.blockNumber, `${name} block number`, /^[1-9][0-9]*$/u)
|
|
37905
37996
|
});
|
|
37906
37997
|
}
|
|
37907
|
-
function recoveryRequest(value, action, name) {
|
|
37998
|
+
function recoveryRequest(value, action, name, chainId) {
|
|
37908
37999
|
const request = object4(value, name);
|
|
37909
|
-
if (request.action !== action
|
|
37910
|
-
|
|
38000
|
+
if (request.action !== action || request.chainId !== void 0 && request.chainId !== chainId) {
|
|
38001
|
+
throw new TypeError(`${name} authority is invalid.`);
|
|
38002
|
+
}
|
|
38003
|
+
return { ...request, chainId };
|
|
37911
38004
|
}
|
|
37912
38005
|
function canonical(value) {
|
|
37913
38006
|
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
@@ -37915,7 +38008,15 @@ function canonical(value) {
|
|
|
37915
38008
|
return JSON.stringify(value);
|
|
37916
38009
|
}
|
|
37917
38010
|
function recoveryFingerprint2(kind, plan, walletAddress2) {
|
|
37918
|
-
|
|
38011
|
+
const authority = object4(plan, "Skill recovery plan");
|
|
38012
|
+
const chainId = skillChain(authority.chainId, "Skill recovery plan chain");
|
|
38013
|
+
return createHash2("sha256").update(canonical({
|
|
38014
|
+
kind,
|
|
38015
|
+
plan,
|
|
38016
|
+
walletAddress: walletAddress2.toLowerCase(),
|
|
38017
|
+
chainId,
|
|
38018
|
+
sourceCommit: skillV3SourceCommit(chainId)
|
|
38019
|
+
})).digest("hex");
|
|
37919
38020
|
}
|
|
37920
38021
|
function recoveryJournal(value, fingerprint2, kind, context) {
|
|
37921
38022
|
const journal = object4(value, "Skill publication recovery");
|
|
@@ -37939,7 +38040,8 @@ function recoveryJournal(value, fingerprint2, kind, context) {
|
|
|
37939
38040
|
"requests",
|
|
37940
38041
|
"receipts"
|
|
37941
38042
|
], "Skill publication recovery");
|
|
37942
|
-
|
|
38043
|
+
const chainId = skillChain(journal.chainId, "Skill recovery chain");
|
|
38044
|
+
if (journal.version !== 4 || journal.kind !== kind || journal.fingerprint !== fingerprint2 || !/^[0-9a-f]{64}$/u.test(fingerprint2) || typeof journal.walletAddress !== "string" || journal.walletAddress.toLowerCase() !== context.walletAddress.toLowerCase()) throw new TypeError("Skill publication recovery authority does not match this command.");
|
|
37943
38045
|
const recoveredAuthority = assertPublicationAuthority(
|
|
37944
38046
|
signingAuthority(journal.signingAuthority, context.walletAddress),
|
|
37945
38047
|
context
|
|
@@ -37960,9 +38062,9 @@ function recoveryJournal(value, fingerprint2, kind, context) {
|
|
|
37960
38062
|
exact(requests, ["primary", "uri", "lit"], "Skill recovery requests");
|
|
37961
38063
|
const receipts = object4(journal.receipts, "Skill recovery receipts");
|
|
37962
38064
|
exact(receipts, ["primary", "uri", "lit"], "Skill recovery receipts");
|
|
37963
|
-
const primary = recoveryRequest(requests.primary, kind === "publish" ? "createSkill" : "updateSkill", "Skill primary recovery request");
|
|
37964
|
-
const uri = requests.uri === null ? null : recoveryRequest(requests.uri, "setSkillURI", "Skill URI recovery request");
|
|
37965
|
-
const lit = requests.lit === null ? null : recoveryRequest(requests.lit, "setLitData", "Skill Lit recovery request");
|
|
38065
|
+
const primary = recoveryRequest(requests.primary, kind === "publish" ? "createSkill" : "updateSkill", "Skill primary recovery request", chainId);
|
|
38066
|
+
const uri = requests.uri === null ? null : recoveryRequest(requests.uri, "setSkillURI", "Skill URI recovery request", chainId);
|
|
38067
|
+
const lit = requests.lit === null ? null : recoveryRequest(requests.lit, "setLitData", "Skill Lit recovery request", chainId);
|
|
37966
38068
|
const parsedReceipts = {
|
|
37967
38069
|
primary: recoveryReceipt(receipts.primary, "Skill primary recovery receipt"),
|
|
37968
38070
|
uri: recoveryReceipt(receipts.uri, "Skill URI recovery receipt"),
|
|
@@ -38014,13 +38116,13 @@ var init_skill_local_flow = __esm({
|
|
|
38014
38116
|
pause;
|
|
38015
38117
|
nonce;
|
|
38016
38118
|
recovery;
|
|
38017
|
-
async send(context, action, request, prepared, onBroadcast) {
|
|
38119
|
+
async send(context, action, request, prepared, authority, onBroadcast) {
|
|
38018
38120
|
return required3(this.sender.submitPrepared, "Skill prepared-intent sender").call(this.sender, {
|
|
38019
38121
|
privateKey: context.privateKey,
|
|
38020
38122
|
walletAddress: context.walletAddress,
|
|
38021
38123
|
action,
|
|
38022
38124
|
request,
|
|
38023
|
-
intent: intent(prepared, context.walletAddress),
|
|
38125
|
+
intent: authority === void 0 ? intent(prepared, context.walletAddress) : legacyIntent(prepared, context.walletAddress, authority),
|
|
38024
38126
|
onBroadcast
|
|
38025
38127
|
});
|
|
38026
38128
|
}
|
|
@@ -38034,10 +38136,18 @@ var init_skill_local_flow = __esm({
|
|
|
38034
38136
|
string4(uri, "Skill package URI", IPFS);
|
|
38035
38137
|
return required3(this.api.fetchSkillStoredContent, "Skill content relay").call(this.api, uri, bearer);
|
|
38036
38138
|
}
|
|
38037
|
-
async contentKey(context, skillId, version6) {
|
|
38038
|
-
const message = buildKeyRequestMessage({ chainId
|
|
38139
|
+
async contentKey(context, chainId, skillId, version6) {
|
|
38140
|
+
const message = buildKeyRequestMessage({ chainId, skillId: BigInt(skillId), version: version6 }, context.walletAddress, this.nonce());
|
|
38039
38141
|
const signature = await this.signer.signMessage({ privateKey: context.privateKey, message });
|
|
38040
|
-
const result2 = await required3(this.api.requestSkillContentKey, "Skill content-key request").call(this.api, {
|
|
38142
|
+
const result2 = await required3(this.api.requestSkillContentKey, "Skill content-key request").call(this.api, {
|
|
38143
|
+
chainId,
|
|
38144
|
+
skillId,
|
|
38145
|
+
version: version6,
|
|
38146
|
+
wallet: context.walletAddress,
|
|
38147
|
+
message,
|
|
38148
|
+
signature,
|
|
38149
|
+
bearer: context.bearer
|
|
38150
|
+
});
|
|
38041
38151
|
if (result2.scheme === SKILL_V3_ENVELOPE_SCHEME) {
|
|
38042
38152
|
return Object.freeze({ scheme: result2.scheme, key: string4(result2.key, "Skill key-encryption key", HASH) });
|
|
38043
38153
|
}
|
|
@@ -38064,32 +38174,35 @@ var init_skill_local_flow = __esm({
|
|
|
38064
38174
|
excluded: sealed.excluded
|
|
38065
38175
|
});
|
|
38066
38176
|
}
|
|
38067
|
-
async protectedEnvelope(context, skillId, version6, mode, packageContentKey) {
|
|
38177
|
+
async protectedEnvelope(context, chainId, skillId, version6, mode, packageContentKey) {
|
|
38068
38178
|
if (mode === "finchip_v2") {
|
|
38069
|
-
const wrapping = await this.contentKey(context, skillId, version6);
|
|
38179
|
+
const wrapping = await this.contentKey(context, chainId, skillId, version6);
|
|
38070
38180
|
if (wrapping.scheme !== SKILL_V3_ENVELOPE_SCHEME) {
|
|
38071
38181
|
throw new TypeError("Finch key authority returned the wrong envelope scheme.");
|
|
38072
38182
|
}
|
|
38073
38183
|
return {
|
|
38074
38184
|
action: "setLitData",
|
|
38185
|
+
chainId,
|
|
38075
38186
|
skillId,
|
|
38076
38187
|
version: version6,
|
|
38077
38188
|
ciphertext: await sealEnvelope(wrapping.key, packageContentKey),
|
|
38078
38189
|
scheme: SKILL_V3_ENVELOPE_SCHEME,
|
|
38079
|
-
chain:
|
|
38190
|
+
chain: skillV3ChainTag(chainId)
|
|
38080
38191
|
};
|
|
38081
38192
|
}
|
|
38082
38193
|
const sealed = await required3(this.api.sealSkillContentKeyWithLit, "Skill Lit sealing").call(this.api, {
|
|
38194
|
+
chainId,
|
|
38083
38195
|
skillId,
|
|
38084
38196
|
version: version6,
|
|
38085
38197
|
contentKey: packageContentKey,
|
|
38086
38198
|
bearer: context.bearer
|
|
38087
38199
|
});
|
|
38088
|
-
if (sealed.scheme !== SKILL_V3_LIT_ENVELOPE_SCHEME || sealed.chain !==
|
|
38200
|
+
if (sealed.scheme !== SKILL_V3_LIT_ENVELOPE_SCHEME || sealed.chain !== skillV3ChainTag(chainId)) {
|
|
38089
38201
|
throw new TypeError("Skill Lit sealing authority is invalid.");
|
|
38090
38202
|
}
|
|
38091
38203
|
return {
|
|
38092
38204
|
action: "setLitData",
|
|
38205
|
+
chainId,
|
|
38093
38206
|
skillId,
|
|
38094
38207
|
version: version6,
|
|
38095
38208
|
ciphertext: string4(sealed.ciphertext, "Skill Lit ciphertext"),
|
|
@@ -38110,24 +38223,31 @@ var init_skill_local_flow = __esm({
|
|
|
38110
38223
|
async save(fingerprint2, journal) {
|
|
38111
38224
|
await required3(this.recovery, "Skill publication recovery").saveSkillPublicationRecovery(fingerprint2, journal);
|
|
38112
38225
|
}
|
|
38113
|
-
async project(transactionHash3, bearer) {
|
|
38114
|
-
await this.api.confirmSkillProjection?.(transactionHash3, bearer);
|
|
38226
|
+
async project(chainId, transactionHash3, bearer) {
|
|
38227
|
+
await this.api.confirmSkillProjection?.(chainId, transactionHash3, bearer);
|
|
38115
38228
|
}
|
|
38116
38229
|
async stage(context, fingerprint2, journal, stage, action, request, prepare) {
|
|
38117
38230
|
const existing = journal.receipts[stage];
|
|
38118
38231
|
if (existing !== null) {
|
|
38119
38232
|
journal.receipts[stage] = await this.verify(context, action, request, existing);
|
|
38120
38233
|
await this.save(fingerprint2, journal);
|
|
38121
|
-
await this.project(journal.receipts[stage].transactionHash, context.bearer);
|
|
38234
|
+
await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer);
|
|
38122
38235
|
return;
|
|
38123
38236
|
}
|
|
38124
38237
|
const prepared = await prepare();
|
|
38125
|
-
journal.receipts[stage] = await this.send(
|
|
38126
|
-
|
|
38127
|
-
|
|
38128
|
-
|
|
38238
|
+
journal.receipts[stage] = await this.send(
|
|
38239
|
+
context,
|
|
38240
|
+
action,
|
|
38241
|
+
request,
|
|
38242
|
+
prepared,
|
|
38243
|
+
journal.signingAuthority,
|
|
38244
|
+
async ({ transactionHash: transactionHash3 }) => {
|
|
38245
|
+
journal.receipts[stage] = { transactionHash: transactionHash3, blockNumber: null };
|
|
38246
|
+
await this.save(fingerprint2, journal);
|
|
38247
|
+
}
|
|
38248
|
+
);
|
|
38129
38249
|
await this.save(fingerprint2, journal);
|
|
38130
|
-
await this.project(journal.receipts[stage].transactionHash, context.bearer);
|
|
38250
|
+
await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer);
|
|
38131
38251
|
}
|
|
38132
38252
|
async recoverPublication(fingerprint2, context) {
|
|
38133
38253
|
if (!/^[0-9a-f]{64}$/u.test(fingerprint2)) throw new TypeError("Skill publication recovery fingerprint is invalid.");
|
|
@@ -38150,7 +38270,12 @@ var init_skill_local_flow = __esm({
|
|
|
38150
38270
|
const slug = string4(journal.requests.primary.slug, "Skill recovery slug");
|
|
38151
38271
|
let skillId2 = journal.skillId;
|
|
38152
38272
|
await this.settle(async () => {
|
|
38153
|
-
skillId2 = await required3(this.api.resolveSkillId, "Skill resolve API").call(
|
|
38273
|
+
skillId2 = await required3(this.api.resolveSkillId, "Skill resolve API").call(
|
|
38274
|
+
this.api,
|
|
38275
|
+
journal.chainId,
|
|
38276
|
+
slug,
|
|
38277
|
+
context.bearer
|
|
38278
|
+
);
|
|
38154
38279
|
return skillId2 !== null;
|
|
38155
38280
|
}, `Skill ${slug} publication`);
|
|
38156
38281
|
if (skillId2 === null) throw new TypeError("Published Skill slug did not resolve.");
|
|
@@ -38160,6 +38285,7 @@ var init_skill_local_flow = __esm({
|
|
|
38160
38285
|
if (journal.requests.lit === null) {
|
|
38161
38286
|
journal.requests.lit = await this.protectedEnvelope(
|
|
38162
38287
|
context,
|
|
38288
|
+
journal.chainId,
|
|
38163
38289
|
skillId2,
|
|
38164
38290
|
1,
|
|
38165
38291
|
journal.contentMode,
|
|
@@ -38180,6 +38306,7 @@ var init_skill_local_flow = __esm({
|
|
|
38180
38306
|
}
|
|
38181
38307
|
await store.clearSkillPublicationRecovery(fingerprint2);
|
|
38182
38308
|
return {
|
|
38309
|
+
chainId: journal.chainId,
|
|
38183
38310
|
skillId: skillId2,
|
|
38184
38311
|
version: 1,
|
|
38185
38312
|
contentMode: journal.contentMode,
|
|
@@ -38204,7 +38331,12 @@ var init_skill_local_flow = __esm({
|
|
|
38204
38331
|
() => required3(this.api.requestSkillIntent, "Skill intent API").call(this.api, journal.requests.primary, context.bearer)
|
|
38205
38332
|
);
|
|
38206
38333
|
await this.settle(
|
|
38207
|
-
async () => await required3(this.api.readSkillCurrentVersion, "Skill version API").call(
|
|
38334
|
+
async () => await required3(this.api.readSkillCurrentVersion, "Skill version API").call(
|
|
38335
|
+
this.api,
|
|
38336
|
+
journal.chainId,
|
|
38337
|
+
skillId,
|
|
38338
|
+
context.bearer
|
|
38339
|
+
) === journal.targetVersion,
|
|
38208
38340
|
`Skill ${skillId} version ${journal.targetVersion}`
|
|
38209
38341
|
);
|
|
38210
38342
|
const uriRequest = required3(journal.requests.uri, "Skill URI recovery request");
|
|
@@ -38221,6 +38353,7 @@ var init_skill_local_flow = __esm({
|
|
|
38221
38353
|
if (journal.requests.lit === null) {
|
|
38222
38354
|
journal.requests.lit = await this.protectedEnvelope(
|
|
38223
38355
|
context,
|
|
38356
|
+
journal.chainId,
|
|
38224
38357
|
skillId,
|
|
38225
38358
|
journal.targetVersion,
|
|
38226
38359
|
journal.contentMode,
|
|
@@ -38241,6 +38374,7 @@ var init_skill_local_flow = __esm({
|
|
|
38241
38374
|
}
|
|
38242
38375
|
await store.clearSkillPublicationRecovery(fingerprint2);
|
|
38243
38376
|
return {
|
|
38377
|
+
chainId: journal.chainId,
|
|
38244
38378
|
skillId,
|
|
38245
38379
|
version: journal.targetVersion,
|
|
38246
38380
|
contentMode: journal.contentMode,
|
|
@@ -38302,7 +38436,7 @@ var init_skill_local_flow = __esm({
|
|
|
38302
38436
|
kind: "publish",
|
|
38303
38437
|
fingerprint: fingerprint2,
|
|
38304
38438
|
walletAddress: context.walletAddress.toLowerCase(),
|
|
38305
|
-
chainId:
|
|
38439
|
+
chainId: plan.chainId,
|
|
38306
38440
|
signingAuthority: plan.signingAuthority,
|
|
38307
38441
|
sourceKind: expectedSourceKind,
|
|
38308
38442
|
contentMode: mode,
|
|
@@ -38330,7 +38464,12 @@ var init_skill_local_flow = __esm({
|
|
|
38330
38464
|
);
|
|
38331
38465
|
let skillId = journal.skillId;
|
|
38332
38466
|
await this.settle(async () => {
|
|
38333
|
-
skillId = await required3(this.api.resolveSkillId, "Skill resolve API").call(
|
|
38467
|
+
skillId = await required3(this.api.resolveSkillId, "Skill resolve API").call(
|
|
38468
|
+
this.api,
|
|
38469
|
+
journal.chainId,
|
|
38470
|
+
String(request.slug),
|
|
38471
|
+
context.bearer
|
|
38472
|
+
);
|
|
38334
38473
|
return skillId !== null;
|
|
38335
38474
|
}, `Skill ${request.slug} publication`);
|
|
38336
38475
|
if (skillId === null) throw new TypeError("Published Skill slug did not resolve.");
|
|
@@ -38340,6 +38479,7 @@ var init_skill_local_flow = __esm({
|
|
|
38340
38479
|
if (journal.requests.lit === null) {
|
|
38341
38480
|
journal.requests.lit = await this.protectedEnvelope(
|
|
38342
38481
|
context,
|
|
38482
|
+
journal.chainId,
|
|
38343
38483
|
skillId,
|
|
38344
38484
|
1,
|
|
38345
38485
|
journal.contentMode,
|
|
@@ -38359,14 +38499,19 @@ var init_skill_local_flow = __esm({
|
|
|
38359
38499
|
);
|
|
38360
38500
|
}
|
|
38361
38501
|
await store.clearSkillPublicationRecovery(fingerprint2);
|
|
38362
|
-
return { skillId, version: 1, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { create: required3(journal.receipts.primary, "Skill create receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required3(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
|
|
38502
|
+
return { chainId: journal.chainId, skillId, version: 1, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { create: required3(journal.receipts.primary, "Skill create receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required3(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
|
|
38363
38503
|
}
|
|
38364
38504
|
async publishVersion(path, planValue, context) {
|
|
38365
38505
|
const plan = versionPlan(planValue, context);
|
|
38366
38506
|
const fingerprint2 = recoveryFingerprint2("version", planValue, context.walletAddress);
|
|
38367
38507
|
const store = required3(this.recovery, "Skill publication recovery");
|
|
38368
38508
|
const prior = await store.readSkillPublicationRecovery(fingerprint2);
|
|
38369
|
-
const observedVersion = await required3(this.api.readSkillCurrentVersion, "Skill version API").call(
|
|
38509
|
+
const observedVersion = await required3(this.api.readSkillCurrentVersion, "Skill version API").call(
|
|
38510
|
+
this.api,
|
|
38511
|
+
plan.chainId,
|
|
38512
|
+
String(plan.request.skillId),
|
|
38513
|
+
context.bearer
|
|
38514
|
+
);
|
|
38370
38515
|
if (prior === null && observedVersion !== plan.currentVersion) {
|
|
38371
38516
|
throw new TypeError(`Skill current version ${observedVersion} no longer matches plan version ${plan.currentVersion}.`);
|
|
38372
38517
|
}
|
|
@@ -38399,14 +38544,14 @@ var init_skill_local_flow = __esm({
|
|
|
38399
38544
|
bearer: context.bearer,
|
|
38400
38545
|
objectKind: "manifest"
|
|
38401
38546
|
});
|
|
38402
|
-
const updateRequest = { action: "updateSkill", skillId: plan.request.skillId, mdHash: packaged.packageHash, packageHash: packaged.packageHash };
|
|
38403
|
-
const uriRequest2 = { action: "setSkillURI", skillId: plan.request.skillId, packageURI: manifestURI };
|
|
38547
|
+
const updateRequest = { action: "updateSkill", chainId: plan.chainId, skillId: plan.request.skillId, mdHash: packaged.packageHash, packageHash: packaged.packageHash };
|
|
38548
|
+
const uriRequest2 = { action: "setSkillURI", chainId: plan.chainId, skillId: plan.request.skillId, packageURI: manifestURI };
|
|
38404
38549
|
journal = {
|
|
38405
38550
|
version: 4,
|
|
38406
38551
|
kind: "version",
|
|
38407
38552
|
fingerprint: fingerprint2,
|
|
38408
38553
|
walletAddress: context.walletAddress.toLowerCase(),
|
|
38409
|
-
chainId:
|
|
38554
|
+
chainId: plan.chainId,
|
|
38410
38555
|
signingAuthority: plan.signingAuthority,
|
|
38411
38556
|
sourceKind: plan.sourceKind,
|
|
38412
38557
|
contentMode: plan.contentMode,
|
|
@@ -38432,7 +38577,12 @@ var init_skill_local_flow = __esm({
|
|
|
38432
38577
|
journal.requests.primary,
|
|
38433
38578
|
() => required3(this.api.requestSkillIntent, "Skill intent API").call(this.api, journal.requests.primary, context.bearer)
|
|
38434
38579
|
);
|
|
38435
|
-
await this.settle(async () => await required3(this.api.readSkillCurrentVersion, "Skill version API").call(
|
|
38580
|
+
await this.settle(async () => await required3(this.api.readSkillCurrentVersion, "Skill version API").call(
|
|
38581
|
+
this.api,
|
|
38582
|
+
journal.chainId,
|
|
38583
|
+
String(plan.request.skillId),
|
|
38584
|
+
context.bearer
|
|
38585
|
+
) === plan.nextVersion, `Skill ${plan.request.skillId} version ${plan.nextVersion}`);
|
|
38436
38586
|
const uriRequest = required3(journal.requests.uri, "Skill URI recovery request");
|
|
38437
38587
|
await this.stage(
|
|
38438
38588
|
context,
|
|
@@ -38447,6 +38597,7 @@ var init_skill_local_flow = __esm({
|
|
|
38447
38597
|
if (journal.requests.lit === null) {
|
|
38448
38598
|
journal.requests.lit = await this.protectedEnvelope(
|
|
38449
38599
|
context,
|
|
38600
|
+
journal.chainId,
|
|
38450
38601
|
String(plan.request.skillId),
|
|
38451
38602
|
plan.nextVersion,
|
|
38452
38603
|
journal.contentMode,
|
|
@@ -38466,18 +38617,18 @@ var init_skill_local_flow = __esm({
|
|
|
38466
38617
|
);
|
|
38467
38618
|
}
|
|
38468
38619
|
await store.clearSkillPublicationRecovery(fingerprint2);
|
|
38469
|
-
return { skillId: plan.request.skillId, version: plan.nextVersion, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { update: required3(journal.receipts.primary, "Skill update receipt").transactionHash, setSkillURI: required3(journal.receipts.uri, "Skill URI receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required3(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
|
|
38620
|
+
return { chainId: journal.chainId, skillId: plan.request.skillId, version: plan.nextVersion, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { update: required3(journal.receipts.primary, "Skill update receipt").transactionHash, setSkillURI: required3(journal.receipts.uri, "Skill URI receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required3(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
|
|
38470
38621
|
}
|
|
38471
38622
|
async manage(kind, planValue, context) {
|
|
38472
38623
|
const plan = managePlan(planValue, context.walletAddress, kind);
|
|
38473
38624
|
const action = kind === "price" ? "setUnitPrice" : "setMaxSupply";
|
|
38474
38625
|
const submission = await this.send(context, action, { action, ...plan.request }, plan.intent);
|
|
38475
|
-
await this.project(submission.transactionHash, context.bearer);
|
|
38476
|
-
return { ...submission, skillId: plan.request.skillId, kind };
|
|
38626
|
+
await this.project(plan.chainId, submission.transactionHash, context.bearer);
|
|
38627
|
+
return { ...submission, chainId: plan.chainId, skillId: plan.request.skillId, kind };
|
|
38477
38628
|
}
|
|
38478
38629
|
async publishPresentation(planValue, context) {
|
|
38479
38630
|
const plan = presentationPlan(planValue, context.walletAddress);
|
|
38480
|
-
const liveVersion = await required3(this.api.readSkillCurrentVersion, "Skill version API").call(this.api, plan.skillId, context.bearer);
|
|
38631
|
+
const liveVersion = await required3(this.api.readSkillCurrentVersion, "Skill version API").call(this.api, plan.chainId, plan.skillId, context.bearer);
|
|
38481
38632
|
if (liveVersion !== plan.currentVersion) {
|
|
38482
38633
|
throw new TypeError(`Skill current version ${liveVersion} no longer matches presentation plan version ${plan.currentVersion}.`);
|
|
38483
38634
|
}
|
|
@@ -38490,11 +38641,17 @@ var init_skill_local_flow = __esm({
|
|
|
38490
38641
|
bearer: context.bearer,
|
|
38491
38642
|
objectKind: "manifest"
|
|
38492
38643
|
});
|
|
38493
|
-
const request = { action: "setSkillURI", skillId: plan.skillId, packageURI: manifestURI };
|
|
38644
|
+
const request = { action: "setSkillURI", chainId: plan.chainId, skillId: plan.skillId, packageURI: manifestURI };
|
|
38494
38645
|
const prepared = await required3(this.api.requestSkillIntent, "Skill intent API").call(this.api, request, context.bearer);
|
|
38495
|
-
const submission = await this.send(
|
|
38496
|
-
|
|
38497
|
-
|
|
38646
|
+
const submission = await this.send(
|
|
38647
|
+
context,
|
|
38648
|
+
"setSkillURI",
|
|
38649
|
+
request,
|
|
38650
|
+
prepared,
|
|
38651
|
+
plan.signingAuthority
|
|
38652
|
+
);
|
|
38653
|
+
await this.project(plan.chainId, submission.transactionHash, context.bearer);
|
|
38654
|
+
return { ...submission, chainId: plan.chainId, skillId: plan.skillId, currentVersion: plan.currentVersion, manifestURI };
|
|
38498
38655
|
}
|
|
38499
38656
|
async uploadCover(path, planValue, context) {
|
|
38500
38657
|
const plan = assetPlan(planValue, context.walletAddress);
|
|
@@ -38514,7 +38671,7 @@ var init_skill_local_flow = __esm({
|
|
|
38514
38671
|
objectKind: "cover",
|
|
38515
38672
|
mediaType
|
|
38516
38673
|
});
|
|
38517
|
-
return { skillId: plan.skillId, assetKind: "cover", uri, mediaType, bytes: bytes.byteLength };
|
|
38674
|
+
return { chainId: plan.chainId, skillId: plan.skillId, assetKind: "cover", uri, mediaType, bytes: bytes.byteLength };
|
|
38518
38675
|
}
|
|
38519
38676
|
async download(planValue, context) {
|
|
38520
38677
|
const plan = deliveryPlan(planValue, context);
|
|
@@ -38531,7 +38688,12 @@ var init_skill_local_flow = __esm({
|
|
|
38531
38688
|
if (!HASH.test(expectedHash)) throw new TypeError("Skill delivery has no verifiable plaintext package hash.");
|
|
38532
38689
|
let plaintext = stored;
|
|
38533
38690
|
if (!plan.plaintext) {
|
|
38534
|
-
const resolved = await this.contentKey(
|
|
38691
|
+
const resolved = await this.contentKey(
|
|
38692
|
+
required3(context, "Protected Skill wallet context"),
|
|
38693
|
+
plan.chainId,
|
|
38694
|
+
plan.skillId,
|
|
38695
|
+
plan.version
|
|
38696
|
+
);
|
|
38535
38697
|
const envelopeScheme = String(plan.litData.scheme);
|
|
38536
38698
|
if (resolved.scheme !== envelopeScheme) throw new TypeError("Skill content-key response does not match its on-chain envelope.");
|
|
38537
38699
|
const contentKey = resolved.scheme === SKILL_V3_ENVELOPE_SCHEME ? await openEnvelope(resolved.key, String(plan.litData.ciphertext)) : resolved.key;
|
|
@@ -38539,7 +38701,7 @@ var init_skill_local_flow = __esm({
|
|
|
38539
38701
|
}
|
|
38540
38702
|
const actualHash = await sha256Hex(plaintext);
|
|
38541
38703
|
if (actualHash.toLowerCase() !== expectedHash.toLowerCase()) throw new TypeError("Decrypted Skill package hash does not match its published authority.");
|
|
38542
|
-
return Object.freeze({ bytes: plaintext, skillId: plan.skillId, version: plan.version, packageHash: actualHash });
|
|
38704
|
+
return Object.freeze({ bytes: plaintext, chainId: plan.chainId, skillId: plan.skillId, version: plan.version, packageHash: actualHash });
|
|
38543
38705
|
}
|
|
38544
38706
|
};
|
|
38545
38707
|
}
|
|
@@ -39797,7 +39959,10 @@ var init_application = __esm({
|
|
|
39797
39959
|
environment: authority.session.environment
|
|
39798
39960
|
});
|
|
39799
39961
|
const published = await required4(this.skillLocalFlow, "skill local flow").publish(path, plan, context);
|
|
39800
|
-
return { ...published, nextAction: { operationId: "skill_market.skills.get", request: {
|
|
39962
|
+
return { ...published, nextAction: { operationId: "skill_market.skills.get", request: {
|
|
39963
|
+
chainId: published.chainId,
|
|
39964
|
+
skillId: published.skillId
|
|
39965
|
+
} } };
|
|
39801
39966
|
}
|
|
39802
39967
|
async submitSkillVersion(path, planFile) {
|
|
39803
39968
|
const plan = await readBoundedJsonFile(planFile);
|
|
@@ -39811,7 +39976,11 @@ var init_application = __esm({
|
|
|
39811
39976
|
environment: authority.session.environment
|
|
39812
39977
|
});
|
|
39813
39978
|
const published = await required4(this.skillLocalFlow, "skill local flow").publishVersion(path, plan, context);
|
|
39814
|
-
return { ...published, nextAction: { operationId: "skill_market.skills.get", request: {
|
|
39979
|
+
return { ...published, nextAction: { operationId: "skill_market.skills.get", request: {
|
|
39980
|
+
chainId: published.chainId,
|
|
39981
|
+
skillId: published.skillId,
|
|
39982
|
+
version: published.version
|
|
39983
|
+
} } };
|
|
39815
39984
|
}
|
|
39816
39985
|
async submitSkillManage(kind, planFile) {
|
|
39817
39986
|
const plan = await readBoundedJsonFile(planFile);
|
|
@@ -39819,7 +39988,10 @@ var init_application = __esm({
|
|
|
39819
39988
|
assertSigningAuthority(plan, authority.session);
|
|
39820
39989
|
const context = Object.freeze({ privateKey: authority.wallet.privateKey, walletAddress: authority.wallet.walletAddress, bearer: authority.session.rawBearer });
|
|
39821
39990
|
const managed = await required4(this.skillLocalFlow, "skill local flow").manage(kind, plan, context);
|
|
39822
|
-
return { ...managed, nextAction: { operationId: "skill_market.skills.get", request: {
|
|
39991
|
+
return { ...managed, nextAction: { operationId: "skill_market.skills.get", request: {
|
|
39992
|
+
chainId: managed.chainId,
|
|
39993
|
+
skillId: managed.skillId
|
|
39994
|
+
} } };
|
|
39823
39995
|
}
|
|
39824
39996
|
async submitSkillPresentation(planFile) {
|
|
39825
39997
|
const plan = await readBoundedJsonFile(planFile);
|
|
@@ -39827,7 +39999,10 @@ var init_application = __esm({
|
|
|
39827
39999
|
assertSigningAuthority(plan, authority.session);
|
|
39828
40000
|
const context = Object.freeze({ privateKey: authority.wallet.privateKey, walletAddress: authority.wallet.walletAddress, bearer: authority.session.rawBearer });
|
|
39829
40001
|
const published = await required4(this.skillLocalFlow, "skill local flow").publishPresentation(plan, context);
|
|
39830
|
-
return { ...published, nextAction: { operationId: "skill_market.manage.get", request: {
|
|
40002
|
+
return { ...published, nextAction: { operationId: "skill_market.manage.get", request: {
|
|
40003
|
+
chainId: published.chainId,
|
|
40004
|
+
skillId: published.skillId
|
|
40005
|
+
} } };
|
|
39831
40006
|
}
|
|
39832
40007
|
async uploadSkillAsset(path, planFile) {
|
|
39833
40008
|
const plan = await readBoundedJsonFile(planFile);
|
|
@@ -39835,7 +40010,10 @@ var init_application = __esm({
|
|
|
39835
40010
|
const uploaded = await required4(this.skillLocalFlow, "skill local flow").uploadCover(path, plan, context);
|
|
39836
40011
|
return { ...uploaded, nextAction: {
|
|
39837
40012
|
operationId: "skill_market.manage.get",
|
|
39838
|
-
|
|
40013
|
+
request: {
|
|
40014
|
+
chainId: uploaded.chainId,
|
|
40015
|
+
skillId: uploaded.skillId
|
|
40016
|
+
}
|
|
39839
40017
|
} };
|
|
39840
40018
|
}
|
|
39841
40019
|
async recoverSkill(kind, fingerprint2) {
|
|
@@ -40170,7 +40348,7 @@ var init_package = __esm({
|
|
|
40170
40348
|
"package.json"() {
|
|
40171
40349
|
package_default = {
|
|
40172
40350
|
name: "@finchtech/cli",
|
|
40173
|
-
version: "0.2.
|
|
40351
|
+
version: "0.2.1",
|
|
40174
40352
|
description: "Finch Agent CLI for wallet-owned marketplace and MCP workflows.",
|
|
40175
40353
|
type: "module",
|
|
40176
40354
|
bin: {
|
|
@@ -55450,6 +55628,38 @@ var init_chainConfig = __esm({
|
|
|
55450
55628
|
}
|
|
55451
55629
|
});
|
|
55452
55630
|
|
|
55631
|
+
// ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/arbitrum.js
|
|
55632
|
+
var arbitrum;
|
|
55633
|
+
var init_arbitrum = __esm({
|
|
55634
|
+
"../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/arbitrum.js"() {
|
|
55635
|
+
init_defineChain();
|
|
55636
|
+
arbitrum = /* @__PURE__ */ defineChain({
|
|
55637
|
+
id: 42161,
|
|
55638
|
+
name: "Arbitrum One",
|
|
55639
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
55640
|
+
blockTime: 250,
|
|
55641
|
+
rpcUrls: {
|
|
55642
|
+
default: {
|
|
55643
|
+
http: ["https://arb1.arbitrum.io/rpc"]
|
|
55644
|
+
}
|
|
55645
|
+
},
|
|
55646
|
+
blockExplorers: {
|
|
55647
|
+
default: {
|
|
55648
|
+
name: "Arbiscan",
|
|
55649
|
+
url: "https://arbiscan.io",
|
|
55650
|
+
apiUrl: "https://api.arbiscan.io/api"
|
|
55651
|
+
}
|
|
55652
|
+
},
|
|
55653
|
+
contracts: {
|
|
55654
|
+
multicall3: {
|
|
55655
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
55656
|
+
blockCreated: 7654707
|
|
55657
|
+
}
|
|
55658
|
+
}
|
|
55659
|
+
});
|
|
55660
|
+
}
|
|
55661
|
+
});
|
|
55662
|
+
|
|
55453
55663
|
// ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/base.js
|
|
55454
55664
|
var sourceId, base, basePreconf;
|
|
55455
55665
|
var init_base2 = __esm({
|
|
@@ -55586,11 +55796,141 @@ var init_baseSepolia = __esm({
|
|
|
55586
55796
|
}
|
|
55587
55797
|
});
|
|
55588
55798
|
|
|
55799
|
+
// ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/bsc.js
|
|
55800
|
+
var bsc;
|
|
55801
|
+
var init_bsc = __esm({
|
|
55802
|
+
"../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/bsc.js"() {
|
|
55803
|
+
init_defineChain();
|
|
55804
|
+
bsc = /* @__PURE__ */ defineChain({
|
|
55805
|
+
id: 56,
|
|
55806
|
+
name: "BNB Smart Chain",
|
|
55807
|
+
blockTime: 750,
|
|
55808
|
+
nativeCurrency: {
|
|
55809
|
+
decimals: 18,
|
|
55810
|
+
name: "BNB",
|
|
55811
|
+
symbol: "BNB"
|
|
55812
|
+
},
|
|
55813
|
+
rpcUrls: {
|
|
55814
|
+
default: { http: ["https://56.rpc.thirdweb.com"] }
|
|
55815
|
+
},
|
|
55816
|
+
blockExplorers: {
|
|
55817
|
+
default: {
|
|
55818
|
+
name: "BscScan",
|
|
55819
|
+
url: "https://bscscan.com",
|
|
55820
|
+
apiUrl: "https://api.bscscan.com/api"
|
|
55821
|
+
}
|
|
55822
|
+
},
|
|
55823
|
+
contracts: {
|
|
55824
|
+
multicall3: {
|
|
55825
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
55826
|
+
blockCreated: 15921452
|
|
55827
|
+
}
|
|
55828
|
+
}
|
|
55829
|
+
});
|
|
55830
|
+
}
|
|
55831
|
+
});
|
|
55832
|
+
|
|
55833
|
+
// ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/mainnet.js
|
|
55834
|
+
var mainnet;
|
|
55835
|
+
var init_mainnet = __esm({
|
|
55836
|
+
"../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/mainnet.js"() {
|
|
55837
|
+
init_defineChain();
|
|
55838
|
+
mainnet = /* @__PURE__ */ defineChain({
|
|
55839
|
+
id: 1,
|
|
55840
|
+
name: "Ethereum",
|
|
55841
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
55842
|
+
blockTime: 12e3,
|
|
55843
|
+
rpcUrls: {
|
|
55844
|
+
default: {
|
|
55845
|
+
http: ["https://ethereum.reth.rs/rpc"]
|
|
55846
|
+
}
|
|
55847
|
+
},
|
|
55848
|
+
blockExplorers: {
|
|
55849
|
+
default: {
|
|
55850
|
+
name: "Etherscan",
|
|
55851
|
+
url: "https://etherscan.io",
|
|
55852
|
+
apiUrl: "https://api.etherscan.io/api"
|
|
55853
|
+
}
|
|
55854
|
+
},
|
|
55855
|
+
contracts: {
|
|
55856
|
+
ensUniversalResolver: {
|
|
55857
|
+
address: "0xeeeeeeee14d718c2b47d9923deab1335e144eeee",
|
|
55858
|
+
blockCreated: 23085558
|
|
55859
|
+
},
|
|
55860
|
+
multicall3: {
|
|
55861
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
55862
|
+
blockCreated: 14353601
|
|
55863
|
+
}
|
|
55864
|
+
}
|
|
55865
|
+
});
|
|
55866
|
+
}
|
|
55867
|
+
});
|
|
55868
|
+
|
|
55869
|
+
// ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/optimism.js
|
|
55870
|
+
var sourceId3, optimism;
|
|
55871
|
+
var init_optimism = __esm({
|
|
55872
|
+
"../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/optimism.js"() {
|
|
55873
|
+
init_chainConfig();
|
|
55874
|
+
init_defineChain();
|
|
55875
|
+
sourceId3 = 1;
|
|
55876
|
+
optimism = /* @__PURE__ */ defineChain({
|
|
55877
|
+
...chainConfig,
|
|
55878
|
+
id: 10,
|
|
55879
|
+
name: "OP Mainnet",
|
|
55880
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
55881
|
+
rpcUrls: {
|
|
55882
|
+
default: {
|
|
55883
|
+
http: ["https://mainnet.optimism.io"]
|
|
55884
|
+
}
|
|
55885
|
+
},
|
|
55886
|
+
blockExplorers: {
|
|
55887
|
+
default: {
|
|
55888
|
+
name: "Optimism Explorer",
|
|
55889
|
+
url: "https://optimistic.etherscan.io",
|
|
55890
|
+
apiUrl: "https://api-optimistic.etherscan.io/api"
|
|
55891
|
+
}
|
|
55892
|
+
},
|
|
55893
|
+
contracts: {
|
|
55894
|
+
...chainConfig.contracts,
|
|
55895
|
+
disputeGameFactory: {
|
|
55896
|
+
[sourceId3]: {
|
|
55897
|
+
address: "0xe5965Ab5962eDc7477C8520243A95517CD252fA9"
|
|
55898
|
+
}
|
|
55899
|
+
},
|
|
55900
|
+
l2OutputOracle: {
|
|
55901
|
+
[sourceId3]: {
|
|
55902
|
+
address: "0xdfe97868233d1aa22e815a266982f2cf17685a27"
|
|
55903
|
+
}
|
|
55904
|
+
},
|
|
55905
|
+
multicall3: {
|
|
55906
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
55907
|
+
blockCreated: 4286263
|
|
55908
|
+
},
|
|
55909
|
+
portal: {
|
|
55910
|
+
[sourceId3]: {
|
|
55911
|
+
address: "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
|
|
55912
|
+
}
|
|
55913
|
+
},
|
|
55914
|
+
l1StandardBridge: {
|
|
55915
|
+
[sourceId3]: {
|
|
55916
|
+
address: "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"
|
|
55917
|
+
}
|
|
55918
|
+
}
|
|
55919
|
+
},
|
|
55920
|
+
sourceId: sourceId3
|
|
55921
|
+
});
|
|
55922
|
+
}
|
|
55923
|
+
});
|
|
55924
|
+
|
|
55589
55925
|
// ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/index.js
|
|
55590
55926
|
var init_chains2 = __esm({
|
|
55591
55927
|
"../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/index.js"() {
|
|
55928
|
+
init_arbitrum();
|
|
55592
55929
|
init_base2();
|
|
55593
55930
|
init_baseSepolia();
|
|
55931
|
+
init_bsc();
|
|
55932
|
+
init_mainnet();
|
|
55933
|
+
init_optimism();
|
|
55594
55934
|
}
|
|
55595
55935
|
});
|
|
55596
55936
|
|
|
@@ -56196,40 +56536,10 @@ function textValue(value, name, allowEmpty = false) {
|
|
|
56196
56536
|
return value;
|
|
56197
56537
|
}
|
|
56198
56538
|
function resolveSkillViemChain(chainId) {
|
|
56199
|
-
|
|
56200
|
-
if (
|
|
56539
|
+
const chain = [mainnet, optimism, bsc, base, arbitrum, baseSepolia].find((candidate) => candidate.id === chainId);
|
|
56540
|
+
if (chain !== void 0) return chain;
|
|
56201
56541
|
throw new TypeError(`Unsupported Skill chain ${String(chainId)}.`);
|
|
56202
56542
|
}
|
|
56203
|
-
function viemFactory2(rpcUrl) {
|
|
56204
|
-
const transport = http2(parseRpcUrl3(rpcUrl), { retryCount: 0, timeout: 2e4 });
|
|
56205
|
-
return (key, chainId) => {
|
|
56206
|
-
const chain = resolveSkillViemChain(chainId);
|
|
56207
|
-
const account = privateKeyToAccount(key);
|
|
56208
|
-
const publicClient = createPublicClient({ chain, transport });
|
|
56209
|
-
const walletClient = createWalletClient({ account, chain, transport });
|
|
56210
|
-
return Object.freeze({
|
|
56211
|
-
walletAddress: account.address.toLowerCase(),
|
|
56212
|
-
getChainId: () => publicClient.getChainId(),
|
|
56213
|
-
sendTransaction: (input) => walletClient.sendTransaction({ account, chain, ...input }),
|
|
56214
|
-
waitForReceipt: async (hash5) => {
|
|
56215
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash: hash5, confirmations: 1, timeout: 12e4 });
|
|
56216
|
-
return Object.freeze({ status: receipt.status, blockNumber: receipt.blockNumber });
|
|
56217
|
-
},
|
|
56218
|
-
getTransactionCall: async (hash5) => {
|
|
56219
|
-
const transaction2 = await publicClient.getTransaction({ hash: hash5 });
|
|
56220
|
-
return Object.freeze({ from: transaction2.from, to: transaction2.to, data: transaction2.input, value: transaction2.value });
|
|
56221
|
-
},
|
|
56222
|
-
getTransactionRecord: async (hash5) => {
|
|
56223
|
-
const [transaction2, receipt] = await Promise.all([
|
|
56224
|
-
publicClient.getTransaction({ hash: hash5 }),
|
|
56225
|
-
publicClient.getTransactionReceipt({ hash: hash5 })
|
|
56226
|
-
]);
|
|
56227
|
-
if (transaction2.blockNumber === null || transaction2.blockNumber !== receipt.blockNumber) throw new TypeError("Skill recovery transaction is not settled in its recorded block.");
|
|
56228
|
-
return Object.freeze({ from: transaction2.from, to: transaction2.to, data: transaction2.input, value: transaction2.value, status: receipt.status, blockNumber: receipt.blockNumber });
|
|
56229
|
-
}
|
|
56230
|
-
});
|
|
56231
|
-
};
|
|
56232
|
-
}
|
|
56233
56543
|
function expectedCall(kind, request, deployment2) {
|
|
56234
56544
|
const skillId = () => unsigned2(request.skillId, "Skill id", true);
|
|
56235
56545
|
if (kind === "purchase") {
|
|
@@ -56289,7 +56599,7 @@ function assertIntentMatches(raw, expected, chainId) {
|
|
|
56289
56599
|
throw new TypeError("Skill intent calldata, target, or value does not match its reviewed request.");
|
|
56290
56600
|
}
|
|
56291
56601
|
}
|
|
56292
|
-
var import_ajv3, instanceAbi, tokenAbi, revenueAbi, factoryAbi, validateIntent2, InstalledSkillIntentSender;
|
|
56602
|
+
var import_ajv3, instanceAbi, tokenAbi, revenueAbi, factoryAbi, validateIntent2, viemFactory2, InstalledSkillIntentSender;
|
|
56293
56603
|
var init_skill_intent_sender = __esm({
|
|
56294
56604
|
"src/skill-intent-sender.ts"() {
|
|
56295
56605
|
"use strict";
|
|
@@ -56317,34 +56627,80 @@ var init_skill_intent_sender = __esm({
|
|
|
56317
56627
|
"function createSkill((bytes32 mdHash, bytes32 packageHash, string packageURI, string slug, string name, string category, string licenseTypeName, string imageURI, bool plaintext, uint256 unitPrice, uint256 maxSupply, uint96 royaltyBPS, uint256 usageLimit) params)"
|
|
56318
56628
|
]);
|
|
56319
56629
|
validateIntent2 = new import_ajv3.default({ allErrors: true, strict: false }).compile(skillIntentResponseSchema);
|
|
56630
|
+
viemFactory2 = (key, chainId, rpcUrl) => {
|
|
56631
|
+
const transport = http2(parseRpcUrl3(rpcUrl), { retryCount: 0, timeout: 2e4 });
|
|
56632
|
+
const chain = resolveSkillViemChain(chainId);
|
|
56633
|
+
const account = privateKeyToAccount(key);
|
|
56634
|
+
const publicClient = createPublicClient({ chain, transport });
|
|
56635
|
+
const walletClient = createWalletClient({ account, chain, transport });
|
|
56636
|
+
return Object.freeze({
|
|
56637
|
+
walletAddress: account.address.toLowerCase(),
|
|
56638
|
+
getChainId: () => publicClient.getChainId(),
|
|
56639
|
+
sendTransaction: (input) => walletClient.sendTransaction({ account, chain, ...input }),
|
|
56640
|
+
waitForReceipt: async (hash5) => {
|
|
56641
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash: hash5, confirmations: 1, timeout: 12e4 });
|
|
56642
|
+
return Object.freeze({ status: receipt.status, blockNumber: receipt.blockNumber });
|
|
56643
|
+
},
|
|
56644
|
+
getTransactionCall: async (hash5) => {
|
|
56645
|
+
const transaction2 = await publicClient.getTransaction({ hash: hash5 });
|
|
56646
|
+
return Object.freeze({ from: transaction2.from, to: transaction2.to, data: transaction2.input, value: transaction2.value });
|
|
56647
|
+
},
|
|
56648
|
+
getTransactionRecord: async (hash5) => {
|
|
56649
|
+
const [transaction2, receipt] = await Promise.all([
|
|
56650
|
+
publicClient.getTransaction({ hash: hash5 }),
|
|
56651
|
+
publicClient.getTransactionReceipt({ hash: hash5 })
|
|
56652
|
+
]);
|
|
56653
|
+
if (transaction2.blockNumber === null || transaction2.blockNumber !== receipt.blockNumber) throw new TypeError("Skill recovery transaction is not settled in its recorded block.");
|
|
56654
|
+
return Object.freeze({ from: transaction2.from, to: transaction2.to, data: transaction2.input, value: transaction2.value, status: receipt.status, blockNumber: receipt.blockNumber });
|
|
56655
|
+
}
|
|
56656
|
+
});
|
|
56657
|
+
};
|
|
56320
56658
|
InstalledSkillIntentSender = class {
|
|
56659
|
+
constructor(environment3 = resolveSkillProtocolEnvironment(process.env.FINCH_ENVIRONMENT), environmentVariables = process.env, rpcFactory = viemFactory2) {
|
|
56660
|
+
this.environment = environment3;
|
|
56661
|
+
this.environmentVariables = environmentVariables;
|
|
56662
|
+
this.rpcFactory = rpcFactory;
|
|
56663
|
+
}
|
|
56664
|
+
environment;
|
|
56665
|
+
environmentVariables;
|
|
56321
56666
|
rpcFactory;
|
|
56322
|
-
|
|
56323
|
-
|
|
56324
|
-
|
|
56325
|
-
|
|
56326
|
-
|
|
56667
|
+
authority(chainIdValue) {
|
|
56668
|
+
if (!Number.isInteger(chainIdValue) || Number(chainIdValue) < 1) {
|
|
56669
|
+
throw new TypeError("Skill request chain is invalid.");
|
|
56670
|
+
}
|
|
56671
|
+
return getSkillProtocolDeployment(resolveSkillProtocolEnvironment(this.environment), Number(chainIdValue));
|
|
56672
|
+
}
|
|
56673
|
+
async rpc(privateKey3, walletAddress2, deployment2) {
|
|
56674
|
+
const override = this.environmentVariables[`FINCHTECH_RPC_URL_${deployment2.chainId}`];
|
|
56675
|
+
const rpcUrl = parseRpcUrl3(override ?? deployment2.defaultRpcUrls[0]);
|
|
56676
|
+
const rpc = this.rpcFactory(installedPrivateKey2(privateKey3), deployment2.chainId, rpcUrl);
|
|
56677
|
+
if (rpc.walletAddress.toLowerCase() !== walletAddress2.toLowerCase() || await rpc.getChainId() !== deployment2.chainId) {
|
|
56678
|
+
throw new TypeError("The wallet or RPC chain does not match the selected Skill authority.");
|
|
56679
|
+
}
|
|
56680
|
+
return rpc;
|
|
56327
56681
|
}
|
|
56328
56682
|
buyerCall(input) {
|
|
56329
56683
|
if (!validateIntent2(input.intent)) throw new TypeError("Skill intent does not match the frozen contract.");
|
|
56330
|
-
|
|
56684
|
+
const deployment2 = this.authority(input.intent.chainId);
|
|
56685
|
+
if (input.intent.kind !== input.expectedKind || input.intent.sourceCommit !== deployment2.sourceCommit) {
|
|
56686
|
+
throw new TypeError("Skill intent authority is invalid.");
|
|
56687
|
+
}
|
|
56331
56688
|
if (typeof input.intent.walletAddress !== "string" || input.intent.walletAddress.toLowerCase() !== input.walletAddress.toLowerCase()) {
|
|
56332
56689
|
throw new TypeError("Skill intent wallet does not match the active CLI wallet.");
|
|
56333
56690
|
}
|
|
56334
|
-
const
|
|
56335
|
-
|
|
56336
|
-
|
|
56337
|
-
|
|
56338
|
-
|
|
56339
|
-
|
|
56340
|
-
|
|
56341
|
-
|
|
56342
|
-
}
|
|
56343
|
-
return rpc;
|
|
56691
|
+
const request = record4(input.intent.request, "Skill intent request");
|
|
56692
|
+
if (request.chainId !== deployment2.chainId) throw new TypeError("Skill intent request chain is invalid.");
|
|
56693
|
+
const expected = expectedCall(input.expectedKind, request, deployment2);
|
|
56694
|
+
assertIntentMatches(
|
|
56695
|
+
input.intent,
|
|
56696
|
+
expected,
|
|
56697
|
+
deployment2.chainId
|
|
56698
|
+
);
|
|
56699
|
+
return Object.freeze({ expected, deployment: deployment2 });
|
|
56344
56700
|
}
|
|
56345
56701
|
async submit(input) {
|
|
56346
|
-
const expected = this.buyerCall(input);
|
|
56347
|
-
const rpc = await this.
|
|
56702
|
+
const { expected, deployment: deployment2 } = this.buyerCall(input);
|
|
56703
|
+
const rpc = await this.rpc(input.privateKey, input.walletAddress, deployment2);
|
|
56348
56704
|
const transactionHash3 = await rpc.sendTransaction(expected);
|
|
56349
56705
|
await input.onBroadcast?.({ fingerprint: skillBuyerIntentFingerprint(input.intent), transactionHash: transactionHash3 });
|
|
56350
56706
|
const receipt = await rpc.waitForReceipt(transactionHash3);
|
|
@@ -56352,8 +56708,8 @@ var init_skill_intent_sender = __esm({
|
|
|
56352
56708
|
return Object.freeze({ transactionHash: transactionHash3, blockNumber: receipt.blockNumber.toString() });
|
|
56353
56709
|
}
|
|
56354
56710
|
async verifyBuyerIntent(input) {
|
|
56355
|
-
const expected = this.buyerCall(input);
|
|
56356
|
-
const rpc = await this.
|
|
56711
|
+
const { expected, deployment: deployment2 } = this.buyerCall(input);
|
|
56712
|
+
const rpc = await this.rpc(input.privateKey, input.walletAddress, deployment2);
|
|
56357
56713
|
const transactionHash3 = hash4(input.transactionHash, "Skill buyer recovery transaction hash");
|
|
56358
56714
|
const exactTransaction2 = (actual2) => actual2.from.toLowerCase() === input.walletAddress.toLowerCase() && actual2.to?.toLowerCase() === expected.to.toLowerCase() && actual2.data === expected.data && actual2.value === expected.value;
|
|
56359
56715
|
if (input.blockNumber === null) {
|
|
@@ -56372,10 +56728,12 @@ var init_skill_intent_sender = __esm({
|
|
|
56372
56728
|
return Object.freeze({ transactionHash: transactionHash3, blockNumber: actual.blockNumber.toString() });
|
|
56373
56729
|
}
|
|
56374
56730
|
async submitPrepared(input) {
|
|
56375
|
-
const
|
|
56376
|
-
|
|
56377
|
-
|
|
56378
|
-
|
|
56731
|
+
const request = record4(input.request, "Skill prepared request");
|
|
56732
|
+
const deployment2 = this.authority(request.chainId);
|
|
56733
|
+
if (input.intent.chainId !== deployment2.chainId) throw new TypeError("Skill prepared intent chain is invalid.");
|
|
56734
|
+
const expected = expectedPreparedCall(input.action, request, deployment2);
|
|
56735
|
+
assertIntentMatches(input.intent, expected, deployment2.chainId);
|
|
56736
|
+
const rpc = await this.rpc(input.privateKey, input.walletAddress, deployment2);
|
|
56379
56737
|
const transactionHash3 = await rpc.sendTransaction(expected);
|
|
56380
56738
|
await input.onBroadcast?.({ transactionHash: transactionHash3 });
|
|
56381
56739
|
const receipt = await rpc.waitForReceipt(transactionHash3);
|
|
@@ -56383,9 +56741,10 @@ var init_skill_intent_sender = __esm({
|
|
|
56383
56741
|
return Object.freeze({ transactionHash: transactionHash3, blockNumber: receipt.blockNumber.toString() });
|
|
56384
56742
|
}
|
|
56385
56743
|
async verifyPrepared(input) {
|
|
56386
|
-
const
|
|
56387
|
-
|
|
56388
|
-
const expected = expectedPreparedCall(input.action,
|
|
56744
|
+
const request = record4(input.request, "Skill prepared request");
|
|
56745
|
+
const deployment2 = this.authority(request.chainId);
|
|
56746
|
+
const expected = expectedPreparedCall(input.action, request, deployment2);
|
|
56747
|
+
const rpc = await this.rpc(input.privateKey, input.walletAddress, deployment2);
|
|
56389
56748
|
const transactionHash3 = hash4(input.transactionHash, "Skill recovery transaction hash");
|
|
56390
56749
|
const exactTransaction2 = (actual2) => actual2.from.toLowerCase() === input.walletAddress && actual2.to?.toLowerCase() === expected.to.toLowerCase() && actual2.data === expected.data && actual2.value === expected.value;
|
|
56391
56750
|
if (input.blockNumber === null) {
|
|
@@ -56519,15 +56878,6 @@ function resolveInstalledRpcUrls(profile, explicitRpcUrl, command) {
|
|
|
56519
56878
|
task: explicitRpcUrl ?? deployment2.defaultRpcUrls[0]
|
|
56520
56879
|
});
|
|
56521
56880
|
}
|
|
56522
|
-
if (command === "skill") {
|
|
56523
|
-
if (profile.environment === "local") {
|
|
56524
|
-
return explicitRpcUrl === void 0 ? Object.freeze({}) : Object.freeze({ skill: explicitRpcUrl });
|
|
56525
|
-
}
|
|
56526
|
-
const deployment2 = getSkillProtocolDeployment(profile.environment);
|
|
56527
|
-
return Object.freeze({
|
|
56528
|
-
skill: explicitRpcUrl ?? deployment2.defaultRpcUrls[0]
|
|
56529
|
-
});
|
|
56530
|
-
}
|
|
56531
56881
|
return Object.freeze({});
|
|
56532
56882
|
}
|
|
56533
56883
|
async function runInstalledCli(arguments_, environment3 = process.env, authorities = {}) {
|
|
@@ -56541,7 +56891,7 @@ async function runInstalledCli(arguments_, environment3 = process.env, authoriti
|
|
|
56541
56891
|
const signer = new InstalledWalletSigner();
|
|
56542
56892
|
const explicitRpcUrl = profile?.chainId === 8453 ? environment3.FINCHTECH_RPC_URL_8453 : environment3.FINCHTECH_RPC_URL_84532;
|
|
56543
56893
|
const rpcUrls = resolveInstalledRpcUrls(profile, explicitRpcUrl, arguments_[0]);
|
|
56544
|
-
const skillIntentSender =
|
|
56894
|
+
const skillIntentSender = profile === void 0 || arguments_[0] !== "skill" ? void 0 : new InstalledSkillIntentSender(profile.environment, environment3);
|
|
56545
56895
|
const application = new FinchCliApplication({
|
|
56546
56896
|
api,
|
|
56547
56897
|
state,
|