@beclab/olaresid 0.1.1 → 0.1.2
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/CLI.md +1300 -0
- package/README.md +37 -31
- package/TAG.md +589 -0
- package/dist/abi/RootResolver2ABI.d.ts +54 -0
- package/dist/abi/RootResolver2ABI.d.ts.map +1 -0
- package/dist/abi/RootResolver2ABI.js +240 -0
- package/dist/abi/RootResolver2ABI.js.map +1 -0
- package/dist/business/index.d.ts +302 -0
- package/dist/business/index.d.ts.map +1 -0
- package/dist/business/index.js +1209 -0
- package/dist/business/index.js.map +1 -0
- package/dist/business/tag-context.d.ts +219 -0
- package/dist/business/tag-context.d.ts.map +1 -0
- package/dist/business/tag-context.js +537 -0
- package/dist/business/tag-context.js.map +1 -0
- package/dist/cli.js +2085 -39
- package/dist/cli.js.map +1 -1
- package/dist/debug.d.ts.map +1 -1
- package/dist/debug.js +14 -2
- package/dist/debug.js.map +1 -1
- package/dist/index.d.ts +50 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +229 -9
- package/dist/index.js.map +1 -1
- package/dist/utils/crypto-utils.d.ts +130 -0
- package/dist/utils/crypto-utils.d.ts.map +1 -0
- package/dist/utils/crypto-utils.js +402 -0
- package/dist/utils/crypto-utils.js.map +1 -0
- package/dist/utils/error-parser.d.ts +35 -0
- package/dist/utils/error-parser.d.ts.map +1 -0
- package/dist/utils/error-parser.js +202 -0
- package/dist/utils/error-parser.js.map +1 -0
- package/dist/utils/tag-abi-codec.d.ts +69 -0
- package/dist/utils/tag-abi-codec.d.ts.map +1 -0
- package/dist/utils/tag-abi-codec.js +144 -0
- package/dist/utils/tag-abi-codec.js.map +1 -0
- package/dist/utils/tag-type-builder.d.ts +158 -0
- package/dist/utils/tag-type-builder.d.ts.map +1 -0
- package/dist/utils/tag-type-builder.js +410 -0
- package/dist/utils/tag-type-builder.js.map +1 -0
- package/examples/crypto-utilities.ts +140 -0
- package/examples/domain-context.ts +80 -0
- package/examples/generate-mnemonic.ts +149 -0
- package/examples/index.ts +1 -1
- package/examples/ip.ts +171 -0
- package/examples/legacy.ts +10 -10
- package/examples/list-wallets.ts +81 -0
- package/examples/quasar-demo/.eslintrc.js +23 -0
- package/examples/quasar-demo/.quasar/app.js +43 -0
- package/examples/quasar-demo/.quasar/client-entry.js +38 -0
- package/examples/quasar-demo/.quasar/client-prefetch.js +130 -0
- package/examples/quasar-demo/.quasar/quasar-user-options.js +16 -0
- package/examples/quasar-demo/README.md +49 -0
- package/examples/quasar-demo/index.html +11 -0
- package/examples/quasar-demo/package-lock.json +6407 -0
- package/examples/quasar-demo/package.json +36 -0
- package/examples/quasar-demo/quasar.config.js +73 -0
- package/examples/quasar-demo/src/App.vue +13 -0
- package/examples/quasar-demo/src/css/app.scss +1 -0
- package/examples/quasar-demo/src/layouts/MainLayout.vue +21 -0
- package/examples/quasar-demo/src/pages/IndexPage.vue +905 -0
- package/examples/quasar-demo/src/router/index.ts +25 -0
- package/examples/quasar-demo/src/router/routes.ts +11 -0
- package/examples/quasar-demo/tsconfig.json +28 -0
- package/examples/register-subdomain.ts +152 -0
- package/examples/rsa-keypair.ts +148 -0
- package/examples/tag-builder.ts +235 -0
- package/examples/tag-management.ts +534 -0
- package/examples/tag-nested-tuple.ts +190 -0
- package/examples/tag-simple.ts +149 -0
- package/examples/tag-tagger.ts +217 -0
- package/examples/test-nested-tuple-conversion.ts +143 -0
- package/examples/test-type-bytes-parser.ts +70 -0
- package/examples/transfer-domain.ts +197 -0
- package/examples/wallet-management.ts +196 -0
- package/package.json +24 -15
- package/src/abi/RootResolver2ABI.ts +237 -0
- package/src/business/index.ts +1490 -0
- package/src/business/tag-context.ts +713 -0
- package/src/cli.ts +2755 -39
- package/src/debug.ts +17 -2
- package/src/index.ts +300 -14
- package/src/utils/crypto-utils.ts +459 -0
- package/src/utils/error-parser.ts +225 -0
- package/src/utils/tag-abi-codec.ts +158 -0
- package/src/utils/tag-type-builder.ts +469 -0
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env ts-node
|
|
2
|
+
/**
|
|
3
|
+
* Test Type Bytes Parser
|
|
4
|
+
* Verifies that parseTypeBytesToAbiString correctly converts type bytes to ABI strings
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { TagTypeBuilder } from '../src/utils/tag-type-builder';
|
|
8
|
+
|
|
9
|
+
console.log('🧪 Testing Type Bytes Parser\n');
|
|
10
|
+
|
|
11
|
+
interface TestCase {
|
|
12
|
+
name: string;
|
|
13
|
+
typeBytes: string;
|
|
14
|
+
expectedAbi: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const testCases: TestCase[] = [
|
|
18
|
+
// Simple types
|
|
19
|
+
{ name: 'string', typeBytes: '0x03', expectedAbi: 'string' },
|
|
20
|
+
{ name: 'uint8', typeBytes: '0x0101', expectedAbi: 'uint8' },
|
|
21
|
+
{ name: 'uint256', typeBytes: '0x0120', expectedAbi: 'uint256' },
|
|
22
|
+
{ name: 'bool', typeBytes: '0x02', expectedAbi: 'bool' },
|
|
23
|
+
{ name: 'address', typeBytes: '0x07', expectedAbi: 'address' },
|
|
24
|
+
|
|
25
|
+
// Array types
|
|
26
|
+
{ name: 'string[]', typeBytes: '0x0403', expectedAbi: 'string[]' },
|
|
27
|
+
{ name: 'address[]', typeBytes: '0x0407', expectedAbi: 'address[]' },
|
|
28
|
+
|
|
29
|
+
// Complex tuple (from tag-management.ts)
|
|
30
|
+
{
|
|
31
|
+
name: 'userInfo tuple',
|
|
32
|
+
typeBytes: '0x060004030101040702',
|
|
33
|
+
expectedAbi: 'tuple(string,uint8,address[],bool)'
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
let passed = 0;
|
|
38
|
+
let failed = 0;
|
|
39
|
+
|
|
40
|
+
for (const testCase of testCases) {
|
|
41
|
+
try {
|
|
42
|
+
const result = TagTypeBuilder.parseTypeBytesToAbiString(
|
|
43
|
+
testCase.typeBytes
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
if (result === testCase.expectedAbi) {
|
|
47
|
+
console.log(`✅ ${testCase.name}`);
|
|
48
|
+
console.log(` Type bytes: ${testCase.typeBytes}`);
|
|
49
|
+
console.log(` ABI string: ${result}\n`);
|
|
50
|
+
passed++;
|
|
51
|
+
} else {
|
|
52
|
+
console.log(`❌ ${testCase.name} - MISMATCH`);
|
|
53
|
+
console.log(` Type bytes: ${testCase.typeBytes}`);
|
|
54
|
+
console.log(` Expected: ${testCase.expectedAbi}`);
|
|
55
|
+
console.log(` Got: ${result}\n`);
|
|
56
|
+
failed++;
|
|
57
|
+
}
|
|
58
|
+
} catch (error: any) {
|
|
59
|
+
console.log(`❌ ${testCase.name} - ERROR`);
|
|
60
|
+
console.log(` Type bytes: ${testCase.typeBytes}`);
|
|
61
|
+
console.log(` Error: ${error.message}\n`);
|
|
62
|
+
failed++;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.log('============================================================');
|
|
67
|
+
console.log(`Results: ${passed} passed, ${failed} failed`);
|
|
68
|
+
console.log('============================================================\n');
|
|
69
|
+
|
|
70
|
+
process.exit(failed > 0 ? 1 : 0);
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Transfer domain ownership using mnemonic-derived keys
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates how to:
|
|
5
|
+
* 1. Connect to the network with the current owner's wallet
|
|
6
|
+
* 2. Generate or use a mnemonic for the new owner
|
|
7
|
+
* 3. Transfer domain ownership (both NFT and DID)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import OlaresID, { generateMnemonic } from '../src/index';
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
console.log('🔐 Domain Transfer Example\n');
|
|
14
|
+
console.log('='.repeat(60));
|
|
15
|
+
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Step 1: Setup
|
|
18
|
+
// ============================================================================
|
|
19
|
+
console.log('\n📝 Step 1: Setup Network and Wallet');
|
|
20
|
+
console.log('-'.repeat(60));
|
|
21
|
+
|
|
22
|
+
// Check for required environment variables
|
|
23
|
+
if (!process.env.PRIVATE_KEY_OR_MNEMONIC) {
|
|
24
|
+
console.error(
|
|
25
|
+
'❌ Error: PRIVATE_KEY_OR_MNEMONIC environment variable is required'
|
|
26
|
+
);
|
|
27
|
+
console.log('\nUsage:');
|
|
28
|
+
console.log(' export PRIVATE_KEY_OR_MNEMONIC=0x... (private key)');
|
|
29
|
+
console.log(' # Or');
|
|
30
|
+
console.log(
|
|
31
|
+
' export PRIVATE_KEY_OR_MNEMONIC="your twelve words..." (mnemonic)'
|
|
32
|
+
);
|
|
33
|
+
console.log(' npx ts-node examples/transfer-domain.ts\n');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Step 2: Initialize OlaresID
|
|
39
|
+
// ============================================================================
|
|
40
|
+
console.log('\n📝 Step 2: Initialize OlaresID');
|
|
41
|
+
console.log('-'.repeat(60));
|
|
42
|
+
|
|
43
|
+
const olaresId = OlaresID.createTestnet();
|
|
44
|
+
await olaresId.setSigner(process.env.PRIVATE_KEY_OR_MNEMONIC);
|
|
45
|
+
|
|
46
|
+
console.log('✅ OlaresID initialized for OP Sepolia Testnet');
|
|
47
|
+
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// Step 3: Get Domain Information
|
|
50
|
+
// ============================================================================
|
|
51
|
+
console.log('\n📝 Step 3: Get Domain Information');
|
|
52
|
+
console.log('-'.repeat(60));
|
|
53
|
+
|
|
54
|
+
// Replace with your actual domain
|
|
55
|
+
const DOMAIN_NAME = process.env.DOMAIN || '1.com';
|
|
56
|
+
const domain = olaresId.domain(DOMAIN_NAME);
|
|
57
|
+
|
|
58
|
+
console.log(`📋 Domain: ${DOMAIN_NAME}`);
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const domainInfo = await domain.getMetaInfo();
|
|
62
|
+
const currentOwner = await domain.getOwner();
|
|
63
|
+
|
|
64
|
+
console.log('✅ Current domain info:');
|
|
65
|
+
console.log(` - ID (Token ID): ${domainInfo.id}`);
|
|
66
|
+
console.log(` - Owner: ${currentOwner}`);
|
|
67
|
+
console.log(` - DID: ${domainInfo.did}`);
|
|
68
|
+
console.log(` - Note: ${domainInfo.note}`);
|
|
69
|
+
|
|
70
|
+
// Verify ownership
|
|
71
|
+
const isOwner = await domain.isOwner();
|
|
72
|
+
if (!isOwner) {
|
|
73
|
+
console.error(
|
|
74
|
+
`❌ Error: You are not the owner of "${DOMAIN_NAME}"`
|
|
75
|
+
);
|
|
76
|
+
console.error(` Current owner: ${currentOwner}`);
|
|
77
|
+
console.error(` Your address: ${olaresId.signer?.getAddress()}`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
console.log('✅ Ownership verified');
|
|
81
|
+
} catch (error: any) {
|
|
82
|
+
console.error(
|
|
83
|
+
`❌ Error: Domain "${DOMAIN_NAME}" not found or not accessible`
|
|
84
|
+
);
|
|
85
|
+
console.error(` ${error.message}`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ============================================================================
|
|
90
|
+
// Step 4: Generate Mnemonic for New Owner
|
|
91
|
+
// ============================================================================
|
|
92
|
+
console.log('\n📝 Step 4: Generate Mnemonic for New Owner');
|
|
93
|
+
console.log('-'.repeat(60));
|
|
94
|
+
|
|
95
|
+
// Generate a new mnemonic (or use existing one)
|
|
96
|
+
let mnemonic: string;
|
|
97
|
+
if (process.env.NEW_OWNER_MNEMONIC) {
|
|
98
|
+
mnemonic = process.env.NEW_OWNER_MNEMONIC;
|
|
99
|
+
console.log('📝 Using provided mnemonic');
|
|
100
|
+
} else {
|
|
101
|
+
mnemonic = generateMnemonic(12);
|
|
102
|
+
console.log('🔑 Generated 12-word mnemonic:');
|
|
103
|
+
console.log(` ${mnemonic}`);
|
|
104
|
+
console.log(
|
|
105
|
+
'\n⚠️ IMPORTANT: Save this mnemonic securely! It controls the domain after transfer.\n'
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Preview new owner info
|
|
110
|
+
const { deriveDIDFromMnemonic } = await import('../src/utils/crypto-utils');
|
|
111
|
+
const { owner: newOwner, did: newDid } = await deriveDIDFromMnemonic(
|
|
112
|
+
mnemonic
|
|
113
|
+
);
|
|
114
|
+
console.log('👤 New owner (derived from mnemonic):');
|
|
115
|
+
console.log(` - Address: ${newOwner}`);
|
|
116
|
+
console.log(` - DID: ${newDid}`);
|
|
117
|
+
|
|
118
|
+
// ============================================================================
|
|
119
|
+
// Step 5: Confirm Transfer
|
|
120
|
+
// ============================================================================
|
|
121
|
+
console.log('\n📝 Step 5: Confirm Transfer');
|
|
122
|
+
console.log('-'.repeat(60));
|
|
123
|
+
console.log('⚠️ You are about to transfer domain ownership!');
|
|
124
|
+
console.log(` Domain: ${DOMAIN_NAME}`);
|
|
125
|
+
console.log(` From: ${olaresId.signer?.getAddress()}`);
|
|
126
|
+
console.log(` To: ${newOwner}`);
|
|
127
|
+
console.log(
|
|
128
|
+
'\n⏸️ Press Ctrl+C to cancel, or wait 5 seconds to continue...\n'
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
// Wait 5 seconds
|
|
132
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
133
|
+
|
|
134
|
+
// ============================================================================
|
|
135
|
+
// Step 6: Transfer Domain
|
|
136
|
+
// ============================================================================
|
|
137
|
+
console.log('📝 Step 6: Transfer Domain');
|
|
138
|
+
console.log('-'.repeat(60));
|
|
139
|
+
console.log('⏳ Submitting transactions...\n');
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
const result = await domain.transfer(mnemonic);
|
|
143
|
+
|
|
144
|
+
if (result.success) {
|
|
145
|
+
console.log('✅ Domain transferred successfully!\n');
|
|
146
|
+
console.log('═'.repeat(60));
|
|
147
|
+
console.log('Transfer Details:');
|
|
148
|
+
console.log('═'.repeat(60));
|
|
149
|
+
console.log(`Domain: ${DOMAIN_NAME}`);
|
|
150
|
+
console.log(`New Owner: ${result.data.newOwner}`);
|
|
151
|
+
console.log(`New DID: ${result.data.newDid}`);
|
|
152
|
+
console.log(`Token ID: ${result.data.tokenId}`);
|
|
153
|
+
console.log(`Transfer Tx Hash: ${result.data.transferTxHash}`);
|
|
154
|
+
console.log(`Set DID Tx Hash: ${result.data.setDidTxHash}`);
|
|
155
|
+
console.log(
|
|
156
|
+
`Total Gas Used: ${result.gasUsed?.toString() || 'N/A'}`
|
|
157
|
+
);
|
|
158
|
+
console.log(`Block Number: ${result.blockNumber || 'N/A'}`);
|
|
159
|
+
console.log('═'.repeat(60));
|
|
160
|
+
|
|
161
|
+
console.log('\n🔗 View transactions on block explorer:');
|
|
162
|
+
console.log(
|
|
163
|
+
` Transfer: https://sepolia-optimism.etherscan.io/tx/${result.data.transferTxHash}`
|
|
164
|
+
);
|
|
165
|
+
console.log(
|
|
166
|
+
` Set DID: https://sepolia-optimism.etherscan.io/tx/${result.data.setDidTxHash}`
|
|
167
|
+
);
|
|
168
|
+
} else {
|
|
169
|
+
console.error('❌ Domain transfer failed!');
|
|
170
|
+
console.error(` Error: ${result.error}`);
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
} catch (error: any) {
|
|
174
|
+
console.error('❌ Unexpected error during transfer:');
|
|
175
|
+
console.error(` ${error.message}`);
|
|
176
|
+
if (error.stack) {
|
|
177
|
+
console.error('\nStack trace:');
|
|
178
|
+
console.error(error.stack);
|
|
179
|
+
}
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ============================================================================
|
|
184
|
+
// Done
|
|
185
|
+
// ============================================================================
|
|
186
|
+
console.log('\n✅ Transfer completed successfully!');
|
|
187
|
+
console.log(
|
|
188
|
+
'\n⚠️ Remember: The new owner is controlled by the mnemonic you generated/used.'
|
|
189
|
+
);
|
|
190
|
+
console.log(' Make sure to store it securely!\n');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Run the example
|
|
194
|
+
main().catch((error) => {
|
|
195
|
+
console.error('Fatal error:', error);
|
|
196
|
+
process.exit(1);
|
|
197
|
+
});
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import OlaresID from '../src/index';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Example: EVM and Solana Wallet Management
|
|
5
|
+
*
|
|
6
|
+
* This example demonstrates how to:
|
|
7
|
+
* 1. Add EVM wallets to a domain
|
|
8
|
+
* 2. Remove EVM wallets from a domain
|
|
9
|
+
* 3. List all EVM wallets for a domain
|
|
10
|
+
* 4. Add Solana wallets to a domain
|
|
11
|
+
* 5. Remove Solana wallets from a domain
|
|
12
|
+
* 6. List all Solana wallets for a domain
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Helper function to wait for blockchain indexing
|
|
17
|
+
* @param seconds - Number of seconds to wait
|
|
18
|
+
*/
|
|
19
|
+
async function waitForIndexing(seconds: number = 5) {
|
|
20
|
+
console.log(` ⏳ Waiting ${seconds}s for blockchain indexing...`);
|
|
21
|
+
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
// Initialize OlaresID (using testnet)
|
|
26
|
+
const olaresId = OlaresID.createTestnet();
|
|
27
|
+
|
|
28
|
+
// Set signer (domain owner's private key or mnemonic)
|
|
29
|
+
const domainOwnerKey = process.env.PRIVATE_KEY_OR_MNEMONIC;
|
|
30
|
+
if (!domainOwnerKey) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
'Please set PRIVATE_KEY_OR_MNEMONIC environment variable'
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
await olaresId.setSigner(domainOwnerKey);
|
|
36
|
+
|
|
37
|
+
// The domain to manage wallets for
|
|
38
|
+
const domainName = process.env.DOMAIN_NAME || '1.com';
|
|
39
|
+
const domain = olaresId.domain(domainName);
|
|
40
|
+
|
|
41
|
+
console.log(`\n🔧 Managing wallets for domain: ${domainName}\n`);
|
|
42
|
+
|
|
43
|
+
// ============================================================================
|
|
44
|
+
// EVM Wallet Management
|
|
45
|
+
// ============================================================================
|
|
46
|
+
|
|
47
|
+
console.log('📝 EVM Wallet Management\n');
|
|
48
|
+
|
|
49
|
+
// 1. List current EVM wallets
|
|
50
|
+
console.log('1️⃣ Listing current EVM wallets...');
|
|
51
|
+
const currentEVMWallets = await domain.getEVMWallets();
|
|
52
|
+
console.log(` Found ${currentEVMWallets.length} EVM wallet(s):`);
|
|
53
|
+
currentEVMWallets.forEach((addr, i) => {
|
|
54
|
+
console.log(` ${i + 1}. ${addr}`);
|
|
55
|
+
});
|
|
56
|
+
console.log('');
|
|
57
|
+
|
|
58
|
+
// 2. Add a new EVM wallet (optional - only if you have an EVM private key)
|
|
59
|
+
if (process.env.EVM_WALLET_PRIVATE_KEY) {
|
|
60
|
+
console.log('2️⃣ Adding a new EVM wallet...');
|
|
61
|
+
const addResult = await domain.addEVMWallet(
|
|
62
|
+
process.env.EVM_WALLET_PRIVATE_KEY
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
if (addResult.success) {
|
|
66
|
+
console.log(
|
|
67
|
+
` ✅ Successfully added EVM wallet: ${addResult.data?.address}`
|
|
68
|
+
);
|
|
69
|
+
console.log(` 📝 Transaction hash: ${addResult.transactionHash}`);
|
|
70
|
+
console.log(` ⛽ Gas used: ${addResult.gasUsed?.toString()}`);
|
|
71
|
+
|
|
72
|
+
// Wait for blockchain to index the transaction
|
|
73
|
+
await waitForIndexing(5);
|
|
74
|
+
} else {
|
|
75
|
+
console.log(` ❌ Failed to add EVM wallet: ${addResult.error}`);
|
|
76
|
+
}
|
|
77
|
+
console.log('');
|
|
78
|
+
|
|
79
|
+
// 3. List EVM wallets again to confirm
|
|
80
|
+
console.log('3️⃣ Listing EVM wallets after addition...');
|
|
81
|
+
const updatedEVMWallets = await domain.getEVMWallets();
|
|
82
|
+
console.log(` Found ${updatedEVMWallets.length} EVM wallet(s):`);
|
|
83
|
+
updatedEVMWallets.forEach((addr, i) => {
|
|
84
|
+
console.log(` ${i + 1}. ${addr}`);
|
|
85
|
+
});
|
|
86
|
+
console.log('');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 4. Remove an EVM wallet (optional)
|
|
90
|
+
if (process.env.EVM_WALLET_TO_REMOVE) {
|
|
91
|
+
console.log('4️⃣ Removing an EVM wallet...');
|
|
92
|
+
const removeResult = await domain.removeEVMWallet(
|
|
93
|
+
process.env.EVM_WALLET_TO_REMOVE
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
if (removeResult.success) {
|
|
97
|
+
console.log(
|
|
98
|
+
` ✅ Successfully removed EVM wallet: ${removeResult.data?.address}`
|
|
99
|
+
);
|
|
100
|
+
console.log(
|
|
101
|
+
` 📝 Transaction hash: ${removeResult.transactionHash}`
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// Wait for blockchain to index the transaction
|
|
105
|
+
await waitForIndexing(5);
|
|
106
|
+
} else {
|
|
107
|
+
console.log(
|
|
108
|
+
` ❌ Failed to remove EVM wallet: ${removeResult.error}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
console.log('');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ============================================================================
|
|
115
|
+
// Solana Wallet Management
|
|
116
|
+
// ============================================================================
|
|
117
|
+
|
|
118
|
+
console.log('📝 Solana Wallet Management\n');
|
|
119
|
+
|
|
120
|
+
// 5. List current Solana wallets
|
|
121
|
+
console.log('5️⃣ Listing current Solana wallets...');
|
|
122
|
+
const currentSolanaWallets = await domain.getSolanaWallets();
|
|
123
|
+
console.log(` Found ${currentSolanaWallets.length} Solana wallet(s):`);
|
|
124
|
+
currentSolanaWallets.forEach((addr, i) => {
|
|
125
|
+
console.log(` ${i + 1}. ${addr}`);
|
|
126
|
+
});
|
|
127
|
+
console.log('');
|
|
128
|
+
|
|
129
|
+
// 6. Add a new Solana wallet (optional - only if you have a Solana private key)
|
|
130
|
+
if (process.env.SOLANA_WALLET_PRIVATE_KEY) {
|
|
131
|
+
console.log('6️⃣ Adding a new Solana wallet...');
|
|
132
|
+
const addResult = await domain.addSolanaWallet(
|
|
133
|
+
process.env.SOLANA_WALLET_PRIVATE_KEY
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
if (addResult.success) {
|
|
137
|
+
console.log(
|
|
138
|
+
` ✅ Successfully added Solana wallet: ${addResult.data?.address}`
|
|
139
|
+
);
|
|
140
|
+
console.log(` 📝 Transaction hash: ${addResult.transactionHash}`);
|
|
141
|
+
console.log(` ⛽ Gas used: ${addResult.gasUsed?.toString()}`);
|
|
142
|
+
|
|
143
|
+
// Wait for blockchain to index the transaction
|
|
144
|
+
await waitForIndexing(5);
|
|
145
|
+
} else {
|
|
146
|
+
console.log(
|
|
147
|
+
` ❌ Failed to add Solana wallet: ${addResult.error}`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
console.log('');
|
|
151
|
+
|
|
152
|
+
// 7. List Solana wallets again to confirm
|
|
153
|
+
console.log('7️⃣ Listing Solana wallets after addition...');
|
|
154
|
+
const updatedSolanaWallets = await domain.getSolanaWallets();
|
|
155
|
+
console.log(
|
|
156
|
+
` Found ${updatedSolanaWallets.length} Solana wallet(s):`
|
|
157
|
+
);
|
|
158
|
+
updatedSolanaWallets.forEach((addr, i) => {
|
|
159
|
+
console.log(` ${i + 1}. ${addr}`);
|
|
160
|
+
});
|
|
161
|
+
console.log('');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 8. Remove a Solana wallet (optional)
|
|
165
|
+
if (process.env.SOLANA_WALLET_TO_REMOVE) {
|
|
166
|
+
console.log('8️⃣ Removing a Solana wallet...');
|
|
167
|
+
const removeResult = await domain.removeSolanaWallet(
|
|
168
|
+
process.env.SOLANA_WALLET_TO_REMOVE
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
if (removeResult.success) {
|
|
172
|
+
console.log(
|
|
173
|
+
` ✅ Successfully removed Solana wallet: ${removeResult.data?.address}`
|
|
174
|
+
);
|
|
175
|
+
console.log(
|
|
176
|
+
` 📝 Transaction hash: ${removeResult.transactionHash}`
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
// Wait for blockchain to index the transaction
|
|
180
|
+
await waitForIndexing(5);
|
|
181
|
+
} else {
|
|
182
|
+
console.log(
|
|
183
|
+
` ❌ Failed to remove Solana wallet: ${removeResult.error}`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
console.log('');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
console.log('✨ Done!\n');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Run the example
|
|
193
|
+
main().catch((error) => {
|
|
194
|
+
console.error('❌ Error:', error.message);
|
|
195
|
+
process.exit(1);
|
|
196
|
+
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beclab/olaresid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "DID Contract SDK with CLI tool",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
6
15
|
"bin": {
|
|
7
|
-
"did-cli": "
|
|
16
|
+
"did-cli": "dist/cli.js"
|
|
8
17
|
},
|
|
9
18
|
"scripts": {
|
|
10
19
|
"build": "tsc",
|
|
@@ -28,23 +37,23 @@
|
|
|
28
37
|
"author": "",
|
|
29
38
|
"license": "Terminus License",
|
|
30
39
|
"dependencies": {
|
|
31
|
-
"
|
|
40
|
+
"@solana/web3.js": "^1.87.6",
|
|
41
|
+
"@trustwallet/wallet-core": "^3.2.9",
|
|
42
|
+
"bip39": "^3.1.0",
|
|
43
|
+
"bs58": "^5.0.0",
|
|
44
|
+
"ethers": "^6.9.1",
|
|
45
|
+
"tweetnacl": "^1.0.3",
|
|
46
|
+
"tweetnacl-util": "^0.15.1",
|
|
47
|
+
"varint": "^6.0.0"
|
|
32
48
|
},
|
|
33
49
|
"module": "commonjs",
|
|
34
50
|
"devDependencies": {
|
|
51
|
+
"@types/node": "^20.0.0",
|
|
52
|
+
"@types/varint": "^6.0.3",
|
|
35
53
|
"ts-node": "^10.9.2",
|
|
36
|
-
"typescript": "^5.9.3"
|
|
37
|
-
"@types/node": "^20.0.0"
|
|
54
|
+
"typescript": "^5.9.3"
|
|
38
55
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"types": "./dist/index.d.ts",
|
|
42
|
-
"import": "./dist/index.js",
|
|
43
|
-
"require": "./dist/index.js"
|
|
44
|
-
},
|
|
45
|
-
"./*": [
|
|
46
|
-
"./*",
|
|
47
|
-
"./*.d.ts"
|
|
48
|
-
]
|
|
56
|
+
"directories": {
|
|
57
|
+
"example": "examples"
|
|
49
58
|
}
|
|
50
59
|
}
|