-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
712 additions
and
446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* | ||
|
||
!dist/** | ||
!package.json | ||
!readme.md | ||
!tsup.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import eslintGlobalConfig from "../../eslint.config.mjs"; | ||
|
||
export default [...eslintGlobalConfig]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "@elizaos/plugin-ordinals", | ||
"version": "0.1.7-alpha.2", | ||
"main": "dist/index.js", | ||
"type": "module", | ||
"types": "dist/index.d.ts", | ||
"dependencies": { | ||
"@elizaos/core": "workspace:*", | ||
"@magiceden-oss/runestone-lib": "^1.0.2", | ||
"@mempool/mempool.js": "^3.0.0", | ||
"@noble/curves": "^1.7.0", | ||
"@scure/base": "^1.2.1", | ||
"@scure/btc-signer": "^1.5.0", | ||
"tsup": "8.3.5", | ||
"vitest": "2.1.4" | ||
}, | ||
"scripts": { | ||
"build": "tsup --format esm --dts", | ||
"dev": "tsup --format esm --dts --watch", | ||
"lint": "eslint --fix --cache .", | ||
"test": "vitest run" | ||
}, | ||
"peerDependencies": { | ||
"form-data": "4.0.1", | ||
"whatwg-url": "7.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Plugin } from "@elizaos/core"; | ||
|
||
export const ordinalsPlugin: Plugin = { | ||
name: "ordinals", | ||
description: "Ordinals Plugin for Eliza", | ||
actions: [], | ||
evaluators: [], | ||
providers: [], | ||
}; | ||
|
||
export default ordinalsPlugin; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { encodeRunestone } from "@magiceden-oss/runestone-lib"; | ||
|
||
class Runes { | ||
getRuneBalance() {} | ||
etchRune(){} | ||
mintRune(){} | ||
transferRune(){} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { IAgentRuntime, Memory, Provider, State } from "@elizaos/core"; | ||
import * as btc from "@scure/btc-signer"; | ||
import { secp256k1 } from "@noble/curves/secp256k1"; | ||
import { hex } from "@scure/base"; | ||
import mempoolJS from "@mempool/mempool.js"; | ||
import { MempoolReturn } from "@mempool/mempool.js/lib/interfaces"; | ||
import { IAccount } from "../types"; | ||
|
||
export class WalletProvider { | ||
mempool: MempoolReturn; | ||
account: IAccount; | ||
|
||
constructor(privateKey: string) { | ||
this.account = this.getAccount(privateKey); | ||
this.mempool = mempoolJS({ | ||
hostname: "mempool.space", | ||
}); | ||
} | ||
|
||
getAccount(privateKey: string): IAccount { | ||
const privateKeyA = hex.decode(privateKey); | ||
const publicKey = secp256k1.getPublicKey(privateKeyA, true); | ||
const schnorrPublicKey = btc.utils.pubSchnorr(privateKeyA); | ||
const network = btc.NETWORK; | ||
|
||
const nestedSegwitAddress = btc.p2sh( | ||
btc.p2wpkh(publicKey, network), | ||
network | ||
).address; | ||
|
||
const taprootAddress = btc.p2tr( | ||
schnorrPublicKey, | ||
undefined, | ||
network | ||
).address; | ||
|
||
return { | ||
nestedSegwitAddress, | ||
taprootAddress, | ||
privateKey, | ||
}; | ||
} | ||
|
||
getAddresses() { | ||
return { | ||
nestedSegwitAddress: this.account.nestedSegwitAddress, | ||
taprootAddress: this.account.taprootAddress, | ||
}; | ||
} | ||
|
||
async getBalance() { | ||
const data = await this.mempool.bitcoin.addresses.getAddress({ | ||
address: this.account.nestedSegwitAddress, | ||
}); | ||
return data?.mempool_stats?.funded_txo_sum || 0; | ||
} | ||
|
||
async getTransactionHistory() { | ||
return await this.mempool.bitcoin.addresses.getAddressTxs({ | ||
address: this.account.nestedSegwitAddress, | ||
}); | ||
} | ||
|
||
async getTransactionStatus(txid: string) { | ||
return await this.mempool.bitcoin.transactions.getTxStatus({ txid }); | ||
} | ||
|
||
async signPsbt(){} | ||
} | ||
|
||
const walletProvider: Provider = { | ||
get: async ( | ||
runtime: IAgentRuntime, | ||
_message: Memory, | ||
_state?: State | ||
): Promise<string | null> => { | ||
try { | ||
const BTC_PK = runtime.getSetting("BITCOIN_PRIVATE_KEY"); | ||
const provider = new WalletProvider(BTC_PK); | ||
const balance = await provider.getBalance(); | ||
const addresses = provider.getAddresses(); | ||
|
||
return `Ordinals wallet => ${addresses.nestedSegwitAddress} / ${addresses.taprootAddress} | Balance: ${balance}`; | ||
} catch (error) { | ||
console.error("Error in wallet provider:", error); | ||
return null; | ||
} | ||
}, | ||
}; | ||
|
||
// Module exports | ||
export { walletProvider }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface IAccount { | ||
nestedSegwitAddress: string; | ||
taprootAddress: string; | ||
privateKey?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../core/tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": "src" | ||
}, | ||
"include": [ | ||
"src/**/*.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { defineConfig } from "tsup"; | ||
|
||
export default defineConfig({ | ||
entry: ["src/index.ts"], | ||
outDir: "dist", | ||
sourcemap: true, | ||
clean: true, | ||
format: ["esm"], // Ensure you're targeting CommonJS | ||
external: [ | ||
"dotenv", // Externalize dotenv to prevent bundling | ||
"fs", // Externalize fs to use Node.js built-in module | ||
"path", // Externalize other built-ins if necessary | ||
"@reflink/reflink", | ||
"@node-llama-cpp", | ||
"https", | ||
"http", | ||
"agentkeepalive", | ||
"safe-buffer", | ||
"base-x", | ||
"bs58", | ||
"borsh", | ||
"@solana/buffer-layout", | ||
"stream", | ||
"buffer", | ||
"querystring", | ||
"amqplib", | ||
// Add other modules you want to externalize | ||
], | ||
}); |
Oops, something went wrong.