@hybrd/xmtp 1.0.0
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/.cache/tsbuildinfo.json +1 -0
- package/.turbo/turbo-typecheck.log +5 -0
- package/README.md +380 -0
- package/biome.jsonc +4 -0
- package/package.json +46 -0
- package/scripts/generate-keys.ts +25 -0
- package/scripts/refresh-identity.ts +119 -0
- package/scripts/register-wallet.ts +95 -0
- package/scripts/revoke-all-installations.ts +91 -0
- package/scripts/revoke-installations.ts +94 -0
- package/src/abi/l2_resolver.ts +699 -0
- package/src/client.ts +940 -0
- package/src/constants.ts +6 -0
- package/src/index.ts +129 -0
- package/src/lib/message-listener.test.ts +369 -0
- package/src/lib/message-listener.ts +343 -0
- package/src/lib/subjects.ts +89 -0
- package/src/localStorage.ts.old +203 -0
- package/src/resolver/address-resolver.ts +221 -0
- package/src/resolver/basename-resolver.ts +585 -0
- package/src/resolver/ens-resolver.ts +324 -0
- package/src/resolver/index.ts +1 -0
- package/src/resolver/resolver.ts +336 -0
- package/src/resolver/xmtp-resolver.ts +436 -0
- package/src/service-client.ts +286 -0
- package/src/transactionMonitor.ts.old +275 -0
- package/src/types.ts +157 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Signer } from "@xmtp/node-sdk"
|
|
2
|
+
import { createXMTPClient, validateEnvironment } from "../src/client"
|
|
3
|
+
import { revokeOldInstallations } from "./revoke-installations"
|
|
4
|
+
|
|
5
|
+
async function revokeAllInstallations() {
|
|
6
|
+
console.log("š Revoking ALL XMTP Installations")
|
|
7
|
+
console.log("==================================")
|
|
8
|
+
|
|
9
|
+
// Validate environment
|
|
10
|
+
const { XMTP_WALLET_KEY } = validateEnvironment(["XMTP_WALLET_KEY"])
|
|
11
|
+
|
|
12
|
+
if (!XMTP_WALLET_KEY) {
|
|
13
|
+
console.error("ā XMTP_WALLET_KEY is required")
|
|
14
|
+
process.exit(1)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
console.log(`š Environment: ${process.env.XMTP_ENV || "dev"}`)
|
|
19
|
+
|
|
20
|
+
// Try to create client to get current inbox ID
|
|
21
|
+
try {
|
|
22
|
+
const client = await createXMTPClient(XMTP_WALLET_KEY)
|
|
23
|
+
const currentInboxId = client.inboxId
|
|
24
|
+
|
|
25
|
+
console.log(`š§ Current Inbox ID: ${currentInboxId}`)
|
|
26
|
+
console.log("š§ Attempting to revoke all installations for this inbox...")
|
|
27
|
+
|
|
28
|
+
const success = await revokeOldInstallations(
|
|
29
|
+
client.signer as Signer,
|
|
30
|
+
currentInboxId
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
// Create signer
|
|
34
|
+
console.log(`š Wallet Address: ${client.accountIdentifier?.identifier}`)
|
|
35
|
+
|
|
36
|
+
if (success) {
|
|
37
|
+
console.log("ā
Successfully revoked all installations")
|
|
38
|
+
} else {
|
|
39
|
+
console.log("ā Failed to revoke installations")
|
|
40
|
+
process.exit(1)
|
|
41
|
+
}
|
|
42
|
+
} catch (clientError) {
|
|
43
|
+
console.log(
|
|
44
|
+
"ā ļø Could not create client, attempting alternative approach..."
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
// If we can't create a client, it might be because of installation limits
|
|
48
|
+
// Try to manually construct possible inbox IDs or use a different approach
|
|
49
|
+
console.log("š This might indicate installation limit issues")
|
|
50
|
+
console.log("š” You may need to:")
|
|
51
|
+
console.log(" 1. Wait a few minutes and try again")
|
|
52
|
+
console.log(" 2. Use the specific inbox ID if you know it")
|
|
53
|
+
console.log(" 3. Try switching XMTP environments (dev <-> production)")
|
|
54
|
+
|
|
55
|
+
throw clientError
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error("š„ Error revoking installations:", error)
|
|
59
|
+
|
|
60
|
+
if (error instanceof Error) {
|
|
61
|
+
if (error.message.includes("5/5 installations")) {
|
|
62
|
+
console.log("\nš” Installation limit reached. Possible solutions:")
|
|
63
|
+
console.log(" 1. Wait 24 hours for installations to expire")
|
|
64
|
+
console.log(
|
|
65
|
+
" 2. Try switching XMTP environments (dev <-> production)"
|
|
66
|
+
)
|
|
67
|
+
console.log(" 3. Use a different wallet")
|
|
68
|
+
} else if (error.message.includes("Missing existing member")) {
|
|
69
|
+
console.log(
|
|
70
|
+
"\nš” This inbox ID may not exist or may be on a different environment"
|
|
71
|
+
)
|
|
72
|
+
console.log(
|
|
73
|
+
" 1. Check if you're using the correct XMTP_ENV (dev vs production)"
|
|
74
|
+
)
|
|
75
|
+
console.log(" 2. Verify the inbox ID is correct")
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
process.exit(1)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Run if called directly
|
|
84
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
85
|
+
revokeAllInstallations().catch((error) => {
|
|
86
|
+
console.error("š„ Fatal error:", error)
|
|
87
|
+
process.exit(1)
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { revokeAllInstallations }
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Client, Signer, createSigner } from "../src/index"
|
|
2
|
+
|
|
3
|
+
// Function to revoke old installations when hitting the limit
|
|
4
|
+
export async function revokeOldInstallations(signer: Signer, inboxId?: string) {
|
|
5
|
+
console.log("š§ Attempting to revoke old installations...")
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
// If we don't have the inboxId, we need to extract it from a temporary client attempt
|
|
9
|
+
if (!inboxId) {
|
|
10
|
+
console.log("ā¹ļø No inboxId provided, cannot revoke installations")
|
|
11
|
+
return false
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const inboxStates = await Client.inboxStateFromInboxIds(
|
|
15
|
+
[inboxId],
|
|
16
|
+
process.env.XMTP_ENV as "dev" | "production"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
if (!inboxStates[0]) {
|
|
20
|
+
console.log("ā No inbox state found for the provided inboxId")
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const toRevokeInstallationBytes = inboxStates[0].installations.map(
|
|
25
|
+
(i) => i.bytes
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
await Client.revokeInstallations(
|
|
29
|
+
signer,
|
|
30
|
+
inboxId,
|
|
31
|
+
toRevokeInstallationBytes,
|
|
32
|
+
process.env.XMTP_ENV as "dev" | "production"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const resultingStates = await Client.inboxStateFromInboxIds(
|
|
36
|
+
[inboxId],
|
|
37
|
+
process.env.XMTP_ENV as "dev" | "production"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
console.log(
|
|
41
|
+
`š Revoked installations: ${toRevokeInstallationBytes.length} installations`
|
|
42
|
+
)
|
|
43
|
+
console.log(
|
|
44
|
+
`š Resulting state: ${resultingStates[0]?.installations.length || 0} installations`
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return true
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error("ā Error during installation revocation:", error)
|
|
50
|
+
return false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// CLI script to revoke installations
|
|
55
|
+
async function main() {
|
|
56
|
+
const { XMTP_WALLET_KEY } = process.env
|
|
57
|
+
const inboxId = process.argv[2]
|
|
58
|
+
|
|
59
|
+
if (!XMTP_WALLET_KEY) {
|
|
60
|
+
console.error("ā XMTP_WALLET_KEY is required")
|
|
61
|
+
process.exit(1)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!inboxId) {
|
|
65
|
+
console.error("ā InboxID is required as CLI argument")
|
|
66
|
+
console.error("Usage: tsx revoke-installations.ts <inboxId>")
|
|
67
|
+
process.exit(1)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const signer = createSigner(XMTP_WALLET_KEY)
|
|
71
|
+
const identifier = await signer.getIdentifier()
|
|
72
|
+
const address = identifier.identifier
|
|
73
|
+
|
|
74
|
+
console.log(`š Wallet Address: ${address}`)
|
|
75
|
+
console.log(`š Inbox ID: ${inboxId}`)
|
|
76
|
+
|
|
77
|
+
// Try to revoke installations
|
|
78
|
+
const success = await revokeOldInstallations(signer, inboxId)
|
|
79
|
+
|
|
80
|
+
if (success) {
|
|
81
|
+
console.log("ā
Successfully revoked installations")
|
|
82
|
+
} else {
|
|
83
|
+
console.log("ā Failed to revoke installations")
|
|
84
|
+
process.exit(1)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Run if called directly
|
|
89
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
90
|
+
main().catch((error) => {
|
|
91
|
+
console.error("š„ Fatal error:", error)
|
|
92
|
+
process.exit(1)
|
|
93
|
+
})
|
|
94
|
+
}
|