diff --git a/.gitignore b/.gitignore index 6e27c24..07684b6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ target **/*.rs.bk node_modules **/node_modules +**/lib **/yarn-error.log **/.yarn **/test-ledger \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 039b918..ec0611c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -560,7 +560,7 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "ephemeral-rollups-sdk" -version = "0.0.2" +version = "0.0.3" dependencies = [ "borsh 0.10.3", "ephemeral-rollups-sdk-attribute-delegate", @@ -570,7 +570,7 @@ dependencies = [ [[package]] name = "ephemeral-rollups-sdk-attribute-delegate" -version = "0.0.2" +version = "0.0.3" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index cc01a33..3c3bdad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.0.2" +version = "0.0.3" authors = ["Magicblock Labs "] edition = "2021" license = "MIT" @@ -17,7 +17,7 @@ readme = "./README.md" keywords = ["solana", "crypto", "delegation", "ephemeral-rollups", "magicblock"] [workspace.dependencies] -ephemeral-rollups-sdk-attribute-delegate = { path = "sdk/delegate", version = "=0.0.2" } +ephemeral-rollups-sdk-attribute-delegate = { path = "sdk/delegate", version = "=0.0.3" } ## External crates borsh = "0.10.3" diff --git a/sdk/ts/lib/accounts.d.ts b/sdk/ts/lib/accounts.d.ts deleted file mode 100644 index 755dd36..0000000 --- a/sdk/ts/lib/accounts.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { PublicKey } from "@solana/web3.js"; -export declare function DelegateAccounts(accountToDelegate: PublicKey, ownerProgram: PublicKey): { - delegationPda: PublicKey; - delegationMetadata: PublicKey; - bufferPda: PublicKey; - commitStateRecordPda: PublicKey; - commitStatePda: PublicKey; -}; -export declare function UndelegateAccounts(accountToDelegate: PublicKey, ownerProgram: PublicKey): { - delegationPda: PublicKey; - delegationMetadata: PublicKey; - bufferPda: PublicKey; - commitStateRecordPda: PublicKey; - commitStatePda: PublicKey; -}; -//# sourceMappingURL=accounts.d.ts.map \ No newline at end of file diff --git a/sdk/ts/lib/accounts.d.ts.map b/sdk/ts/lib/accounts.d.ts.map deleted file mode 100644 index 19dae15..0000000 --- a/sdk/ts/lib/accounts.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAiB5C,wBAAgB,gBAAgB,CAC9B,iBAAiB,EAAE,SAAS,EAC5B,YAAY,EAAE,SAAS;;;;;;EAGxB;AAQD,wBAAgB,kBAAkB,CAChC,iBAAiB,EAAE,SAAS,EAC5B,YAAY,EAAE,SAAS;;;;;;EAGxB"} \ No newline at end of file diff --git a/sdk/ts/lib/accounts.js b/sdk/ts/lib/accounts.js deleted file mode 100644 index 69123d4..0000000 --- a/sdk/ts/lib/accounts.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UndelegateAccounts = exports.DelegateAccounts = void 0; -var web3_js_1 = require("@solana/web3.js"); -var seeds_1 = require("./seeds"); -var constants_1 = require("./constants"); -function DelegateAccounts(accountToDelegate, ownerProgram) { - return getAccounts(accountToDelegate, ownerProgram, true); -} -exports.DelegateAccounts = DelegateAccounts; -function UndelegateAccounts(accountToDelegate, ownerProgram) { - return getAccounts(accountToDelegate, ownerProgram, false); -} -exports.UndelegateAccounts = UndelegateAccounts; -function getAccounts(accountToDelegate, ownerProgram, ownedBuffer) { - if (ownedBuffer === void 0) { ownedBuffer = true; } - var pdaBytes = accountToDelegate.toBytes(); - var delegationPda = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(seeds_1.SEED_DELEGATION), pdaBytes], new web3_js_1.PublicKey(constants_1.DELEGATION_PROGRAM_ID))[0]; - var delegationMetadata = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(seeds_1.SEED_DELEGATION_METADATA), pdaBytes], new web3_js_1.PublicKey(constants_1.DELEGATION_PROGRAM_ID))[0]; - var bufferPda = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(seeds_1.SEED_BUFFER_PDA), pdaBytes], ownedBuffer - ? new web3_js_1.PublicKey(ownerProgram) - : new web3_js_1.PublicKey(constants_1.DELEGATION_PROGRAM_ID))[0]; - var commitStateRecordPda = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(seeds_1.SEED_COMMIT_STATE_RECORD_PDA), pdaBytes], new web3_js_1.PublicKey(constants_1.DELEGATION_PROGRAM_ID))[0]; - var commitStatePda = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(seeds_1.SEED_STATE_DIFF_PDA), pdaBytes], new web3_js_1.PublicKey(constants_1.DELEGATION_PROGRAM_ID))[0]; - return { - delegationPda: delegationPda, - delegationMetadata: delegationMetadata, - bufferPda: bufferPda, - commitStateRecordPda: commitStateRecordPda, - commitStatePda: commitStatePda, - }; -} -//# sourceMappingURL=accounts.js.map \ No newline at end of file diff --git a/sdk/ts/lib/accounts.js.map b/sdk/ts/lib/accounts.js.map deleted file mode 100644 index 6a612a6..0000000 --- a/sdk/ts/lib/accounts.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":";;;AAAA,2CAA4C;AAC5C,iCAMiB;AAEjB,yCAAoD;AAQpD,SAAgB,gBAAgB,CAC9B,iBAA4B,EAC5B,YAAuB;IAEvB,OAAO,WAAW,CAAC,iBAAiB,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;AAC5D,CAAC;AALD,4CAKC;AAQD,SAAgB,kBAAkB,CAChC,iBAA4B,EAC5B,YAAuB;IAEvB,OAAO,WAAW,CAAC,iBAAiB,EAAE,Y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oB,sBAAA;QACpB,cAAc,gBAAA;KACf,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/sdk/ts/lib/constants.d.ts b/sdk/ts/lib/constants.d.ts deleted file mode 100644 index 11576d3..0000000 --- a/sdk/ts/lib/constants.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare const DELEGATION_PROGRAM_ID = "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh"; -export declare const MAGIC_PROGRAM_ID = "Magic11111111111111111111111111111111111111"; -//# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/sdk/ts/lib/constants.d.ts.map b/sdk/ts/lib/constants.d.ts.map deleted file mode 100644 index 91079a0..0000000 --- a/sdk/ts/lib/constants.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,iDACc,CAAC;AAEjD,eAAO,MAAM,gBAAgB,gDAAgD,CAAC"} \ No newline at end of file diff --git a/sdk/ts/lib/constants.js b/sdk/ts/lib/constants.js deleted file mode 100644 index 59b14fe..0000000 --- a/sdk/ts/lib/constants.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.MAGIC_PROGRAM_ID = exports.DELEGATION_PROGRAM_ID = void 0; -exports.DELEGATION_PROGRAM_ID = "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh"; -exports.MAGIC_PROGRAM_ID = "Magic11111111111111111111111111111111111111"; -//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/sdk/ts/lib/constants.js.map b/sdk/ts/lib/constants.js.map deleted file mode 100644 index ee8fbed..0000000 --- a/sdk/ts/lib/constants.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAChC,8CAA8C,CAAC;AAEpC,QAAA,gBAAgB,GAAG,6CAA6C,CAAC"} \ No newline at end of file diff --git a/sdk/ts/lib/index.d.ts b/sdk/ts/lib/index.d.ts deleted file mode 100644 index c161702..0000000 --- a/sdk/ts/lib/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./seeds"; -export * from "./constants"; -export * from "./instructions/undelegate"; -export * from "./instructions/trigger-commit"; -export * from "./accounts"; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/sdk/ts/lib/index.d.ts.map b/sdk/ts/lib/index.d.ts.map deleted file mode 100644 index 090795b..0000000 --- a/sdk/ts/lib/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,YAAY,CAAC"} \ No newline at end of file diff --git a/sdk/ts/lib/index.js b/sdk/ts/lib/index.js deleted file mode 100644 index 1fc9e7d..0000000 --- a/sdk/ts/lib/index.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -__exportStar(require("./seeds"), exports); -__exportStar(require("./constants"), exports); -__exportStar(require("./instructions/undelegate"), exports); -__exportStar(require("./instructions/trigger-commit"), exports); -__exportStar(require("./accounts"), exports); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/sdk/ts/lib/index.js.map b/sdk/ts/lib/index.js.map deleted file mode 100644 index 9c7a506..0000000 --- a/sdk/ts/lib/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,8CAA4B;AAC5B,4DAA0C;AAC1C,gEAA8C;AAC9C,6CAA2B"} \ No newline at end of file diff --git a/sdk/ts/lib/instructions/trigger-commit.d.ts b/sdk/ts/lib/instructions/trigger-commit.d.ts deleted file mode 100644 index 18dc32a..0000000 --- a/sdk/ts/lib/instructions/trigger-commit.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as beet from "@metaplex-foundation/beet"; -import * as web3 from "@solana/web3.js"; -export declare const commitStruct: beet.FixableBeetArgsStruct<{ - instructionDiscriminator: number[]; -}>; -export interface CommitInstructionAccounts { - payer: web3.PublicKey; - delegatedAccount: web3.PublicKey; -} -export declare const commitInstructionDiscriminator: number[]; -export declare function createCommitInstruction(accounts: CommitInstructionAccounts, programId?: web3.PublicKey): web3.TransactionInstruction; -//# sourceMappingURL=trigger-commit.d.ts.map \ No newline at end of file diff --git a/sdk/ts/lib/instructions/trigger-commit.d.ts.map b/sdk/ts/lib/instructions/trigger-commit.d.ts.map deleted file mode 100644 index 7841c86..0000000 --- a/sdk/ts/lib/instructions/trigger-commit.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"trigger-commit.d.ts","sourceRoot":"","sources":["../../src/instructions/trigger-commit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAIxC,eAAO,MAAM,YAAY;8BACG,MAAM,EAAE;EAInC,CAAC;AAMF,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;IACtB,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC;CAClC;AAED,eAAO,MAAM,8BAA8B,UAAe,CAAC;AAO3D,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,yBAAyB,EACnC,SAAS,iBAAkC,+BAwB5C"} \ No newline at end of file diff --git a/sdk/ts/lib/instructions/trigger-commit.js b/sdk/ts/lib/instructions/trigger-commit.js deleted file mode 100644 index 3e708e3..0000000 --- a/sdk/ts/lib/instructions/trigger-commit.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createCommitInstruction = exports.commitInstructionDiscriminator = exports.commitStruct = void 0; -var beet = __importStar(require("@metaplex-foundation/beet")); -var web3 = __importStar(require("@solana/web3.js")); -var web3_js_1 = require("@solana/web3.js"); -var constants_1 = require("../constants"); -exports.commitStruct = new beet.FixableBeetArgsStruct([["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 4)]], "CommitInstructionArgs"); -exports.commitInstructionDiscriminator = [1, 0, 0, 0]; -function createCommitInstruction(accounts, programId) { - if (programId === void 0) { programId = new web3_js_1.PublicKey(constants_1.MAGIC_PROGRAM_ID); } - var data = exports.commitStruct.serialize({ - instructionDiscriminator: exports.commitInstructionDiscriminator, - })[0]; - var keys = [ - { - pubkey: accounts.payer, - isWritable: false, - isSigner: true, - }, - { - pubkey: accounts.delegatedAccount, - isWritable: true, - isSigner: false, - }, - ]; - return new web3.TransactionInstruction({ - programId: programId, - keys: keys, - data: data, - }); -} -exports.createCommitInstruction = createCommitInstruction; -//# sourceMappingURL=trigger-commit.js.map \ No newline at end of file diff --git a/sdk/ts/lib/instructions/trigger-commit.js.map b/sdk/ts/lib/instructions/trigger-commit.js.map deleted file mode 100644 index 9d0a724..0000000 --- a/sdk/ts/lib/instructions/trigger-commit.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"trigger-commit.js","sourceRoot":"","sources":["../../src/instructions/trigger-commit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAkD;AAClD,oDAAwC;AACxC,2CAA4C;AAC5C,0CAAgD;AAEnC,QAAA,YAAY,GAAG,IAAI,IAAI,CAAC,qBAAqB,CAGxD,CAAC,CAAC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACtE,uBAAuB,CACxB,CAAC;AAWW,QAAA,8BAA8B,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAO3D,SAAgB,uBAAuB,CACrC,QAAmC,EACnC,SAA2C;IAA3C,0BAAA,EAAA,gBAAgB,mBAAS,CAAC,4BAAgB,CAAC;IAEpC,IAAA,IAAI,GAAI,oBAAY,CAAC,SAAS,CAAC;QACpC,wBAAwB,EAAE,sCAA8B;KACzD,CAAC,GAFS,CAER;IAEH,IAAM,IAAI,GAAuB;QAC/B;YACE,MAAM,EAAE,QAAQ,CAAC,KAAK;YACtB,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,IAAI;SACf;QACD;YACE,MAAM,EAAE,QAAQ,CAAC,gBAAgB;YACjC,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,KAAK;SAChB;KACF,CAAC;IAEF,OAAO,IAAI,IAAI,CAAC,sBAAsB,CAAC;QACrC,SAAS,WAAA;QACT,IAAI,MAAA;QACJ,IAAI,MAAA;KACL,CAAC,CAAC;AACL,CAAC;AA1BD,0DA0BC"} \ No newline at end of file diff --git a/sdk/ts/lib/instructions/undelegate.d.ts b/sdk/ts/lib/instructions/undelegate.d.ts deleted file mode 100644 index 7ed528d..0000000 --- a/sdk/ts/lib/instructions/undelegate.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import * as beet from "@metaplex-foundation/beet"; -import * as web3 from "@solana/web3.js"; -export declare const undelegateStruct: beet.FixableBeetArgsStruct<{ - instructionDiscriminator: number[]; -}>; -export interface UndelegateInstructionAccounts { - payer: web3.PublicKey; - delegatedAccount: web3.PublicKey; - ownerProgram: web3.PublicKey; - buffer?: web3.PublicKey; - commitStatePda?: web3.PublicKey; - commitStateRecordPda?: web3.PublicKey; - delegationRecord?: web3.PublicKey; - delegationMetadata?: web3.PublicKey; - reimbursement: web3.PublicKey; - systemProgram?: web3.PublicKey; -} -export declare const undelegateInstructionDiscriminator: number[]; -export declare function createUndelegateInstruction(accounts: UndelegateInstructionAccounts, programId?: web3.PublicKey): web3.TransactionInstruction; -//# sourceMappingURL=undelegate.d.ts.map \ No newline at end of file diff --git a/sdk/ts/lib/instructions/undelegate.d.ts.map b/sdk/ts/lib/instructions/undelegate.d.ts.map deleted file mode 100644 index 822c74c..0000000 --- a/sdk/ts/lib/instructions/undelegate.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"undelegate.d.ts","sourceRoot":"","sources":["../../src/instructions/undelegate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAKxC,eAAO,MAAM,gBAAgB;8BACD,MAAM,EAAE;EAInC,CAAC;AAMF,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;IACtB,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC;IACjC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACxB,cAAc,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAChC,oBAAoB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACtC,gBAAgB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAClC,kBAAkB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACpC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC;IAC9B,aAAa,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;CAChC;AAED,eAAO,MAAM,kCAAkC,UAA2B,CAAC;AAO3E,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,6BAA6B,EACvC,SAAS,iBAAuC,+BAwEjD"} \ No newline at end of file diff --git a/sdk/ts/lib/instructions/undelegate.js b/sdk/ts/lib/instructions/undelegate.js deleted file mode 100644 index 1e3da4f..0000000 --- a/sdk/ts/lib/instructions/undelegate.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createUndelegateInstruction = exports.undelegateInstructionDiscriminator = exports.undelegateStruct = void 0; -var beet = __importStar(require("@metaplex-foundation/beet")); -var web3 = __importStar(require("@solana/web3.js")); -var accounts_1 = require("../accounts"); -var web3_js_1 = require("@solana/web3.js"); -var constants_1 = require("../constants"); -exports.undelegateStruct = new beet.FixableBeetArgsStruct([["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]], "UndelegateInstructionArgs"); -exports.undelegateInstructionDiscriminator = [3, 0, 0, 0, 0, 0, 0, 0]; -function createUndelegateInstruction(accounts, programId) { - var _a, _b, _c, _d, _e, _f; - if (programId === void 0) { programId = new web3_js_1.PublicKey(constants_1.DELEGATION_PROGRAM_ID); } - var data = exports.undelegateStruct.serialize({ - instructionDiscriminator: exports.undelegateInstructionDiscriminator, - })[0]; - var _g = (0, accounts_1.UndelegateAccounts)(accounts.delegatedAccount, accounts.ownerProgram), delegationPda = _g.delegationPda, delegationMetadata = _g.delegationMetadata, bufferPda = _g.bufferPda, commitStateRecordPda = _g.commitStateRecordPda, commitStatePda = _g.commitStatePda; - var keys = [ - { - pubkey: accounts.payer, - isWritable: false, - isSigner: true, - }, - { - pubkey: accounts.delegatedAccount, - isWritable: true, - isSigner: false, - }, - { - pubkey: accounts.ownerProgram, - isWritable: false, - isSigner: false, - }, - { - pubkey: (_a = accounts.buffer) !== null && _a !== void 0 ? _a : bufferPda, - isWritable: true, - isSigner: false, - }, - { - pubkey: (_b = accounts.commitStatePda) !== null && _b !== void 0 ? _b : commitStatePda, - isWritable: true, - isSigner: false, - }, - { - pubkey: (_c = accounts.commitStateRecordPda) !== null && _c !== void 0 ? _c : commitStateRecordPda, - isWritable: true, - isSigner: false, - }, - { - pubkey: (_d = accounts.delegationRecord) !== null && _d !== void 0 ? _d : delegationPda, - isWritable: true, - isSigner: false, - }, - { - pubkey: (_e = accounts.delegationMetadata) !== null && _e !== void 0 ? _e : delegationMetadata, - isWritable: true, - isSigner: false, - }, - { - pubkey: accounts.reimbursement, - isWritable: false, - isSigner: false, - }, - { - pubkey: (_f = accounts.systemProgram) !== null && _f !== void 0 ? _f : web3.SystemProgram.programId, - isWritable: false, - isSigner: false, - }, - ]; - return new web3.TransactionInstruction({ - programId: programId, - keys: keys, - data: data, - }); -} -exports.createUndelegateInstruction = createUndelegateInstruction; -//# sourceMappingURL=undelegate.js.map \ No newline at end of file diff --git a/sdk/ts/lib/instructions/undelegate.js.map b/sdk/ts/lib/instructions/undelegate.js.map deleted file mode 100644 index 4831b54..0000000 --- a/sdk/ts/lib/instructions/undelegate.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"undelegate.js","sourceRoot":"","sources":["../../src/instructions/undelegate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAkD;AAClD,oDAAwC;AACxC,wCAAiD;AACjD,2CAA4C;AAC5C,0CAAqD;AAExC,QAAA,gBAAgB,GAAG,IAAI,IAAI,CAAC,qBAAqB,CAG5D,CAAC,CAAC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACtE,2BAA2B,CAC5B,CAAC;AAmBW,QAAA,kCAAkC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAO3E,SAAgB,2BAA2B,CACzC,QAAuC,EACvC,SAAgD;;IAAhD,0BAAA,EAAA,gBAAgB,mBAAS,CAAC,iCAAqB,CAAC;IAEzC,IAAA,IAAI,GAAI,wBAAgB,CAAC,SAAS,CAAC;QACxC,wBAAwB,EAAE,0CAAkC;KAC7D,CAAC,GAFS,CAER;IAEG,IAAA,KAMF,IAAA,6BAAkB,EAAC,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,YAAY,CAAC,EALtE,aAAa,mBAAA,EACb,kBAAkB,wBAAA,EAClB,SAAS,eAAA,EACT,oBAAoB,0BAAA,EACpB,cAAc,oBACwD,CAAC;IAEzE,IAAM,IAAI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,MAAA;KACL,CAAC,CAAC;AACL,CAAC;AA1ED,kEA0EC"} \ No newline at end of file diff --git a/sdk/ts/lib/seeds.d.ts b/sdk/ts/lib/seeds.d.ts deleted file mode 100644 index 5eea0bb..0000000 --- a/sdk/ts/lib/seeds.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export declare const SEED_TEST_PDA = "test-pda"; -export declare const SEED_BUFFER_PDA = "buffer"; -export declare const SEED_DELEGATION = "delegation"; -export declare const SEED_DELEGATION_METADATA = "delegation-metadata"; -export declare const SEED_COMMIT_STATE_RECORD_PDA = "commit-state-record"; -export declare const SEED_STATE_DIFF_PDA = "state-diff"; -//# sourceMappingURL=seeds.d.ts.map \ No newline at end of file diff --git a/sdk/ts/lib/seeds.d.ts.map b/sdk/ts/lib/seeds.d.ts.map deleted file mode 100644 index 1e81fb8..0000000 --- a/sdk/ts/lib/seeds.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"seeds.d.ts","sourceRoot":"","sources":["../src/seeds.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAC9D,eAAO,MAAM,4BAA4B,wBAAwB,CAAC;AAClE,eAAO,MAAM,mBAAmB,eAAe,CAAC"} \ No newline at end of file diff --git a/sdk/ts/lib/seeds.js b/sdk/ts/lib/seeds.js deleted file mode 100644 index e3123cf..0000000 --- a/sdk/ts/lib/seeds.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SEED_STATE_DIFF_PDA = exports.SEED_COMMIT_STATE_RECORD_PDA = exports.SEED_DELEGATION_METADATA = exports.SEED_DELEGATION = exports.SEED_BUFFER_PDA = exports.SEED_TEST_PDA = void 0; -exports.SEED_TEST_PDA = "test-pda"; -exports.SEED_BUFFER_PDA = "buffer"; -exports.SEED_DELEGATION = "delegation"; -exports.SEED_DELEGATION_METADATA = "delegation-metadata"; -exports.SEED_COMMIT_STATE_RECORD_PDA = "commit-state-record"; -exports.SEED_STATE_DIFF_PDA = "state-diff"; -//# sourceMappingURL=seeds.js.map \ No newline at end of file diff --git a/sdk/ts/lib/seeds.js.map b/sdk/ts/lib/seeds.js.map deleted file mode 100644 index 93478bd..0000000 --- a/sdk/ts/lib/seeds.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"seeds.js","sourceRoot":"","sources":["../src/seeds.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,UAAU,CAAC;AAC3B,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,eAAe,GAAG,YAAY,CAAC;AAC/B,QAAA,wBAAwB,GAAG,qBAAqB,CAAC;AACjD,QAAA,4BAA4B,GAAG,qBAAqB,CAAC;AACrD,QAAA,mBAAmB,GAAG,YAAY,CAAC"} \ No newline at end of file diff --git a/sdk/ts/package.json b/sdk/ts/package.json index 6b4047d..eebf5cc 100644 --- a/sdk/ts/package.json +++ b/sdk/ts/package.json @@ -1,6 +1,6 @@ { "name": "@magicblock-labs/ephemeral-rollups-sdk", - "version": "0.0.2", + "version": "0.0.3", "author": "MagicBlock Labs", "license": "MIT", "publishConfig": { diff --git a/sdk/ts/src/index.ts b/sdk/ts/src/index.ts index 09e860f..a79ad24 100644 --- a/sdk/ts/src/index.ts +++ b/sdk/ts/src/index.ts @@ -1,5 +1,5 @@ export * from "./seeds"; export * from "./constants"; export * from "./instructions/undelegate"; -export * from "./instructions/trigger-commit"; export * from "./accounts"; +export * from "./utils"; diff --git a/sdk/ts/src/instructions/trigger-commit.ts b/sdk/ts/src/instructions/trigger-commit.ts deleted file mode 100644 index 323cead..0000000 --- a/sdk/ts/src/instructions/trigger-commit.ts +++ /dev/null @@ -1,55 +0,0 @@ -import * as beet from "@metaplex-foundation/beet"; -import * as web3 from "@solana/web3.js"; -import { PublicKey } from "@solana/web3.js"; -import { MAGIC_PROGRAM_ID } from "../constants"; - -export const commitStruct = new beet.FixableBeetArgsStruct<{ - instructionDiscriminator: number[]; -}>( - [["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 4)]], - "CommitInstructionArgs", -); - -/** - * Accounts required by the _undelegate_ instruction - */ - -export interface CommitInstructionAccounts { - payer: web3.PublicKey; - delegatedAccount: web3.PublicKey; -} - -export const commitInstructionDiscriminator = [1, 0, 0, 0]; - -/** - * Creates an _undelegate_ instruction. - * - */ - -export function createCommitInstruction( - accounts: CommitInstructionAccounts, - programId = new PublicKey(MAGIC_PROGRAM_ID), -) { - const [data] = commitStruct.serialize({ - instructionDiscriminator: commitInstructionDiscriminator, - }); - - const keys: web3.AccountMeta[] = [ - { - pubkey: accounts.payer, - isWritable: false, - isSigner: true, - }, - { - pubkey: accounts.delegatedAccount, - isWritable: true, - isSigner: false, - }, - ]; - - return new web3.TransactionInstruction({ - programId, - keys, - data, - }); -} diff --git a/sdk/ts/src/utils.ts b/sdk/ts/src/utils.ts new file mode 100644 index 0000000..631296a --- /dev/null +++ b/sdk/ts/src/utils.ts @@ -0,0 +1,71 @@ +// eslint-disable-next-line @typescript-eslint/consistent-type-imports +import { Connection } from "@solana/web3.js"; + +/** + * Get the signature of the accounts commitment transaction to the base layer + * @param transactionSignature + * @param ephemeralConnection + * @constructor + */ +export async function GetCommitmentSignature( + transactionSignature: string, + ephemeralConnection: Connection, +): Promise { + const txSchedulingSgn = await ephemeralConnection.getTransaction( + transactionSignature, + { maxSupportedTransactionVersion: 0 }, + ); + if (txSchedulingSgn?.meta == null) { + throw new Error("Transaction not found or meta is null"); + } + + const scheduledCommitSgn = parseScheduleCommitsLogsMessage( + txSchedulingSgn.meta.logMessages ?? [], + ); + if (scheduledCommitSgn == null) { + throw new Error("ScheduledCommitSent signature not found"); + } + + const latestBlockhash = await ephemeralConnection.getLatestBlockhash(); + await ephemeralConnection.confirmTransaction({ + signature: scheduledCommitSgn, + ...latestBlockhash, + }); + + const txCommitInfo = await ephemeralConnection.getTransaction( + scheduledCommitSgn, + { maxSupportedTransactionVersion: 0 }, + ); + if (txCommitInfo?.meta == null) { + throw new Error("Transaction not found or meta is null"); + } + + const commitSignature = parseCommitsLogsMessage( + txCommitInfo.meta.logMessages ?? [], + ); + if (commitSignature == null) { + throw new Error("Unable to find Commitment signature"); + } + + return commitSignature; +} + +function parseScheduleCommitsLogsMessage(logMessages: string[]): string | null { + for (const message of logMessages) { + const signaturePrefix = "ScheduledCommitSent signature: "; + if (message.includes(signaturePrefix)) { + return message.split(signaturePrefix)[1]; + } + } + return null; +} + +function parseCommitsLogsMessage(logMessages: string[]): string | null { + for (const message of logMessages) { + const signaturePrefix = "ScheduledCommitSent signature[0]: "; + if (message.includes(signaturePrefix)) { + return message.split(signaturePrefix)[1]; + } + } + return null; +}