Skip to content

Commit 5d6309f

Browse files
authored
feat: add register on-chain identity on People Chain (#73)
<img width="521" height="123" alt="image" src="https://github.com/user-attachments/assets/cd126169-3ba7-4dcc-8594-f7409446f821" />
1 parent f03920b commit 5d6309f

File tree

22 files changed

+449
-33
lines changed

22 files changed

+449
-33
lines changed

.papi/descriptors/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.1.0-autogenerated.10336401122289269029",
2+
"version": "0.1.0-autogenerated.15063461877034566089",
33
"name": "@polkadot-api/descriptors",
44
"files": [
55
"dist"

.papi/metadata/paseo_people.scale

121 KB
Binary file not shown.

.papi/polkadot-api.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
"metadata": ".papi/metadata/paseo.scale",
4343
"genesis": "0x77afd6190f1554ad45fd0d31aee62aacc33c6db0ea801129acb813f913e0764f",
4444
"codeHash": "0xcc4b027a0dbb5e0f389dd8418c41012d618290a22f84af8411c8fd20b2738304"
45+
},
46+
"paseo_people": {
47+
"chain": "paseo_people",
48+
"metadata": ".papi/metadata/paseo_people.scale",
49+
"genesis": "0x4545454545454545454545454545454545454545454545454545454545454545",
50+
"codeHash": "0xacf9e44512ac871585d8a389914acffbc97f5c767eed9ddef2cc0151e6d19a27"
4551
}
4652
}
4753
}

examples/telegram-bot/src/TelegramBot.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class TelegramBot {
3939

4040
this.agent = new PolkadotAgentKit(privateKey as string, {
4141
keyType: "Sr25519",
42+
chains: ["paseo","paseo_people"]
4243
});
4344

4445
this.llm = this.initializeLLM(openAiApiKey);
@@ -66,6 +67,7 @@ export class TelegramBot {
6667
const unbond = this.agent.unbondTool();
6768
const claimRewards = this.agent.claimRewardsTool();
6869
const withdrawUnbonded = this.agent.withdrawUnbondedTool();
70+
const registerIdentity = this.agent.registerIdentityTool();
6971

7072
setupHandlers(this.bot, this.llm, {
7173
checkBalance: checkBalance,
@@ -76,7 +78,8 @@ export class TelegramBot {
7678
bondExtra: bondExtra,
7779
unbond: unbond,
7880
claimRewards: claimRewards,
79-
withdrawUnbonded: withdrawUnbonded
81+
withdrawUnbonded: withdrawUnbonded,
82+
registerIdentity: registerIdentity
8083
});
8184

8285
console.log("Bot initialization complete");

examples/telegram-bot/src/handlers.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export const SYSTEM_PROMPT = `I am a Telegram bot powered by PolkadotAgentKit. I
88
- Checking WND balance on Westend (e.g., "check balance")
99
- Checking proxies (e.g., "check proxies on westend" or "check proxies")
1010
- Transfer tokens through XCM (e.g., "transfer 1 WND to 5CSox4ZSN4SGLKUG9NYPtfVK9sByXLtxP4hmoF4UgkM4jgDJ from west to westend_asset_hub ")
11+
- Register identity on People Chain (e.g., "register identity display=\"Gemini AI\" web=\"https://gemini.google.com\" twitter=\"@GoogleAI\" github=\"google\"")
12+
- Register identity on People Chain (e.g., "register identity display=\"Gemini AI\" web=\"https://gemini.google.com\" twitter=\"@GoogleAI\" github=\"google\"")
1113
1214
DYNAMIC CHAIN INITIALIZATION:
1315
When balance checking, native transfers, or XCM transfer tools fail because a chain is not available/initialized, I should:
@@ -178,6 +180,14 @@ Example: For "claim rewards from pool on paseo", call claimRewardsTool with:
178180
- CRITICAL: If the user says "amount", use that value for 'slashingSpans'.
179181
- Example: User says "withdraw unbonded with 1 amount on Paseo" -> Call 'withdrawUnbondedTool' with { slashingSpans: "1", chain: "paseo" }
180182
183+
3. To 'register identity' on People Chain:
184+
- Use the 'register_identity' tool.
185+
- - Parameters: any of the optional strings among display, legal, web, matrix, email, image, twitter, github, discord.
186+
- - Example: User says "register identity display="Gemini AI" twitter="@GoogleAI"" -> Call 'register_identity' with { display: "Gemini AI", twitter: "@GoogleAI" }
187+
+ - Parameters: provide at least one of: display, legal, web, matrix, email, image, twitter, github, discord (all strings, optional individually).
188+
+ - Example A: User says "register identity with email abc@gmail.com" -> Call 'register_identity' with { email: "abc@gmail.com" }
189+
+ - Example B: User says "register identity display="Gemini AI" twitter="@GoogleAI"" -> Call 'register_identity' with { display: "Gemini AI", twitter: "@GoogleAI" }
190+
181191
--- END OF TOOL-SPECIFIC RULES ---
182192
183193
When checking proxies, you can specify the chain (convert to real param) or not specify a chain (the first chain will be used by default)
@@ -196,7 +206,8 @@ export function setupHandlers(
196206
'- Transferring native tokens (e.g., "transfer 1 token to westend_asset_hub to 5CSox4ZSN4SGLKUG9NYPtfVK9sByXLtxP4hmoF4UgkM4jgDJ")\n' +
197207
'- Checking balance (e.g., "check balance on west/polkadot/kusama")\n' +
198208
'- Checking proxies (e.g., "check proxies on westend" or "check proxies")\n' +
199-
'- Transfer tokens through XCM (e.g., "transfer 1 WND to 5CSox4ZSN4SGLKUG9NYPtfVK9sByXLtxP4hmoF4UgkM4jgDJ from west to west_asset_hub ")\n' +
209+
'- Transfer tokens through XCM (e.g., "transfer 1 WND to 5CSox4ZSN4SGLKUG9NYPtfVK9sByXLtxP4hmoF4UgkM4jgDJ from west to westend_asset_hub ")\n' +
210+
'- Register identity on People Chain (e.g., "register identity display=\"Gemini AI\" web=\"https://gemini.google.com\" twitter=\"@GoogleAI\" github=\"google\"")' +
200211
'- Bonding to a pool (e.g., "bond 100 DOT on Polkadot")\n' +
201212
'- Re-staking rewards (e.g., "re-stake my rewards on Paseo")\n' +
202213
'- Unbonding tokens from a pool (e.g., "unbond 100 DOT on Polkadot")\n' +
@@ -233,7 +244,8 @@ export function setupHandlers(
233244
await ctx.reply(`Error: ${response.message}`);
234245
} else {
235246
const content = JSON.parse(response.content || "{}");
236-
await ctx.reply(content.data || "No message from tool.");
247+
const data = JSON.stringify(content.data);
248+
await ctx.reply(data || "No message from tool.");
237249
}
238250
} else {
239251
console.warn(`Tool not found: ${toolCall.name}`);

packages/common/src/chains/chains.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
hydra,
33
paseo,
4+
paseo_people,
45
polkadot,
56
polkadot_asset_hub,
67
west,
@@ -9,6 +10,7 @@ import {
910

1011
import {
1112
paseoChain,
13+
paseoPeopleChain,
1214
polkadotAssetHubChain,
1315
polkadotChain,
1416
westendAssetHubChain,
@@ -27,6 +29,7 @@ type DescriptorsAssetHubType = {
2729

2830
type DescriptorsParaType = {
2931
hydra: typeof hydra
32+
paseo_people: typeof paseo_people
3033
}
3134

3235
const DESCRIPTORS_RELAY: DescriptorsRelayType = {
@@ -41,7 +44,8 @@ const DESCRIPTORS_ASSET_HUB: DescriptorsAssetHubType = {
4144
}
4245

4346
const DESCRIPTORS_PARA: DescriptorsParaType = {
44-
hydra
47+
hydra,
48+
paseo_people
4549
}
4650

4751
export const DESCRIPTORS_ALL = {
@@ -111,7 +115,8 @@ const SUPPORTED_CHAINS: Chain[] = [
111115
polkadotAssetHubChain,
112116
westendChain,
113117
westendAssetHubChain,
114-
paseoChain
118+
paseoChain,
119+
paseoPeopleChain
115120
]
116121

117122
export const getAllSupportedChains = (): Chain[] => {

packages/common/src/chains/supported-chains.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,17 @@ export const paseoChain = createChain({
9292
decimals: 10,
9393
symbol: "PAS"
9494
})
95+
96+
export const paseoPeopleChain = createChain({
97+
id: "paseo_people",
98+
name: "PeoplePaseo",
99+
specName: "paseo-people",
100+
wsUrls: ["wss://people-paseo.dotters.network"],
101+
relay: "paseo",
102+
type: "system",
103+
chainId: 1004,
104+
blockExplorerUrl: "https://people-paseo.subscan.io/",
105+
prefix: 0,
106+
decimals: 10,
107+
symbol: "PAS"
108+
})

packages/common/src/clients/chainSpec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { chainSpec as paseoSpec } from "polkadot-api/chains/paseo"
2+
import { chainSpec as paseoPeopleSpec } from "polkadot-api/chains/paseo_people"
23
import { chainSpec as polkadotSpec } from "polkadot-api/chains/polkadot"
34
import { chainSpec as polkadotAssetHubSpec } from "polkadot-api/chains/polkadot_asset_hub"
45
import { chainSpec as westSpec } from "polkadot-api/chains/westend2"
@@ -34,7 +35,6 @@ export function getChainSpec(
3435
if (cachedSpec) {
3536
return cachedSpec
3637
}
37-
3838
// Get spec from registry
3939
const chainSpec = specRegistry[chainId]
4040
if (!chainSpec) {
@@ -74,6 +74,7 @@ export function specRegistry(): Partial<Record<ChainId, string>> {
7474
west: westSpec,
7575
polkadot_asset_hub: polkadotAssetHubSpec,
7676
west_asset_hub: westAssetHubSpec,
77-
paseo: paseoSpec
77+
paseo: paseoSpec,
78+
paseo_people: paseoPeopleSpec
7879
}
7980
}

packages/core/src/api/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export class PolkadotApi implements IPolkadotApi {
103103
polkadot_asset_hub: "",
104104
west_asset_hub: "",
105105
hydra: "",
106-
paseo: ""
106+
paseo: "",
107+
paseo_people: ""
107108
}
108109

109110
for (const chain of supportedChains) {

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
export * from "./api"
33
export * from "./defi/swap"
44
export * from "./pallets/assets"
5+
export * from "./pallets/identity"
56
export * from "./pallets/nomination-pools"
67
export * from "./pallets/xcm"
78
export * from "./types"

0 commit comments

Comments
 (0)