@fastnear/wallet-adapter
Version:
Wallet adapter implementations for Meteor Wallet and Near Mobile
103 lines • 3.96 kB
JavaScript
/* ⋈ 🏃🏻💨 FastNear Wallet Adapters - CJS (@fastnear/wallet-adapter version 1.2.0) */
/* https://www.npmjs.com/package/@fastnear/wallet-adapter/v/1.2.0 */
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var actions_exports = {};
__export(actions_exports, {
connectorActionsToFastnearActions: () => connectorActionsToFastnearActions
});
module.exports = __toCommonJS(actions_exports);
var import_utils = require("@fastnear/utils");
const toBase64Code = /* @__PURE__ */ __name((value) => {
if (typeof value === "string") return value;
if (value instanceof Uint8Array) return (0, import_utils.bytesToBase64)(value);
if (Array.isArray(value)) return (0, import_utils.bytesToBase64)(Uint8Array.from(value));
throw new Error("DeployContract code must be Uint8Array, Array<number>, or base64 string");
}, "toBase64Code");
const connectorActionsToFastnearActions = /* @__PURE__ */ __name((actions) => {
return actions.map((action) => {
if (typeof action !== "object" || action == null) {
throw new Error("Invalid action");
}
if (!("type" in action) || typeof action.type !== "string") {
throw new Error("Action is missing type");
}
switch (action.type) {
case "FunctionCall":
return {
type: "FunctionCall",
methodName: action.params?.methodName,
args: action.params?.args ?? {},
gas: action.params?.gas ?? "30000000000000",
deposit: action.params?.deposit ?? "0"
};
case "Transfer":
return {
type: "Transfer",
deposit: action.params?.deposit
};
case "AddKey":
return {
type: "AddKey",
publicKey: action.params?.publicKey,
accessKey: {
nonce: action.params?.accessKey?.nonce ?? 0,
permission: action.params?.accessKey?.permission === "FullAccess" ? "FullAccess" : {
receiverId: action.params?.accessKey?.permission?.receiverId,
methodNames: action.params?.accessKey?.permission?.methodNames ?? [],
allowance: action.params?.accessKey?.permission?.allowance
}
}
};
case "DeleteKey":
return {
type: "DeleteKey",
publicKey: action.params?.publicKey
};
case "CreateAccount":
return {
type: "CreateAccount"
};
case "DeleteAccount":
return {
type: "DeleteAccount",
beneficiaryId: action.params?.beneficiaryId
};
case "DeployContract":
return {
type: "DeployContract",
codeBase64: toBase64Code(action.params?.code)
};
case "Stake":
return {
type: "Stake",
stake: action.params?.stake,
publicKey: action.params?.publicKey
};
default:
throw new Error(`Unsupported action type: ${action.type}`);
}
});
}, "connectorActionsToFastnearActions");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
connectorActionsToFastnearActions
});
//# sourceMappingURL=actions.cjs.map