@identity.com/cryptid-middleware-check-pass
Advanced tools
Comparing version 0.3.0-alpha.5 to 0.3.0-alpha.6
import { ExecuteMiddlewareParams, GenericMiddlewareParams, MiddlewareClient } from "@identity.com/cryptid-core"; | ||
import { PublicKey, Transaction, TransactionInstruction } from "@solana/web3.js"; | ||
export declare const CHECK_PASS_MIDDLEWARE_PROGRAM_ID: PublicKey; | ||
export declare const deriveMiddlewareAccountAddress: (authority: PublicKey, gatekeeperNetwork: PublicKey, failsafe?: PublicKey, previousMiddlewareAccount?: PublicKey) => [PublicKey, number]; | ||
export declare type CheckPassParameters = { | ||
@@ -13,3 +14,4 @@ gatekeeperNetwork: PublicKey; | ||
createMiddleware(params: CheckPassParameters): Promise<Transaction>; | ||
executeMiddleware(params: ExecuteMiddlewareParams): Promise<TransactionInstruction>; | ||
onPropose(): Promise<TransactionInstruction[]>; | ||
onExecute(params: ExecuteMiddlewareParams): Promise<TransactionInstruction[]>; | ||
} |
@@ -35,3 +35,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CheckPassMiddleware = exports.CHECK_PASS_MIDDLEWARE_PROGRAM_ID = void 0; | ||
exports.CheckPassMiddleware = exports.deriveMiddlewareAccountAddress = exports.CHECK_PASS_MIDDLEWARE_PROGRAM_ID = void 0; | ||
const cryptid_core_1 = require("@identity.com/cryptid-core"); | ||
@@ -53,7 +53,13 @@ const web3_js_1 = require("@solana/web3.js"); | ||
}); | ||
const deriveMiddlewareAccountAddress = (authority, gatekeeperNetwork) => web3_js_1.PublicKey.findProgramAddressSync([ | ||
anchor.utils.bytes.utf8.encode("check_pass"), | ||
authority.toBuffer(), | ||
gatekeeperNetwork.toBuffer(), | ||
], exports.CHECK_PASS_MIDDLEWARE_PROGRAM_ID); | ||
const deriveMiddlewareAccountAddress = (authority, gatekeeperNetwork, failsafe, previousMiddlewareAccount) => { | ||
const seeds = [ | ||
anchor.utils.bytes.utf8.encode("check_pass"), | ||
authority.toBuffer(), | ||
gatekeeperNetwork.toBuffer(), | ||
(failsafe === null || failsafe === void 0 ? void 0 : failsafe.toBuffer()) || Buffer.alloc(32), | ||
(previousMiddlewareAccount === null || previousMiddlewareAccount === void 0 ? void 0 : previousMiddlewareAccount.toBuffer()) || Buffer.alloc(32), | ||
]; | ||
return web3_js_1.PublicKey.findProgramAddressSync(seeds, exports.CHECK_PASS_MIDDLEWARE_PROGRAM_ID); | ||
}; | ||
exports.deriveMiddlewareAccountAddress = deriveMiddlewareAccountAddress; | ||
const getExpireFeatureAddress = (gatekeeperNetwork) => (0, solana_gateway_ts_1.getFeatureAccountAddress)(expireFeature, gatekeeperNetwork); | ||
@@ -69,5 +75,5 @@ class CheckPassMiddleware { | ||
const program = CheckPassMiddleware.getProgram(params); | ||
const [middlewareAccount, middlewareBump] = deriveMiddlewareAccountAddress(params.authority.publicKey, params.gatekeeperNetwork); | ||
const [middlewareAccount, middlewareBump] = (0, exports.deriveMiddlewareAccountAddress)(params.authority.publicKey, params.gatekeeperNetwork, params.failsafe, params.previousMiddleware); | ||
return program.methods | ||
.create(params.gatekeeperNetwork, middlewareBump, params.expirePassOnUse, params.failsafe || null) | ||
.create(params.gatekeeperNetwork, middlewareBump, params.expirePassOnUse, params.failsafe || null, params.previousMiddleware || null) | ||
.accounts({ | ||
@@ -80,4 +86,9 @@ middlewareAccount, | ||
} | ||
executeMiddleware(params) { | ||
onPropose() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return []; | ||
}); | ||
} | ||
onExecute(params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const program = CheckPassMiddleware.getProgram(params); | ||
@@ -99,3 +110,4 @@ const middlewareAccount = yield program.account.checkPass.fetch(params.middlewareAccount); | ||
}) | ||
.instruction(); | ||
.instruction() | ||
.then(Array.of); | ||
}); | ||
@@ -102,0 +114,0 @@ } |
{ | ||
"name": "@identity.com/cryptid-middleware-check-pass", | ||
"version": "0.3.0-alpha.5", | ||
"version": "0.3.0-alpha.6", | ||
"main": "dist/index.js", | ||
@@ -16,6 +16,7 @@ "types": "dist/index.d.ts", | ||
"dependencies": { | ||
"@identity.com/cryptid-core": "0.3.0-alpha.5", | ||
"@identity.com/cryptid-core": "0.3.0-alpha.6", | ||
"@identity.com/solana-gateway-ts": "^0.8.2", | ||
"@solana/web3.js": "^1.62.0" | ||
"@solana/web3.js": "^1.62.0", | ||
"bn.js": "^5.2.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
10323
127
4
+ Addedbn.js@^5.2.1
+ Added@identity.com/cryptid-core@0.3.0-alpha.6(transitive)
+ Added@identity.com/cryptid-idl@0.3.0-alpha.6(transitive)
- Removed@identity.com/cryptid-core@0.3.0-alpha.5(transitive)
- Removed@identity.com/cryptid-idl@0.3.0-alpha.5(transitive)