@akita-protocol/algomd-rn 1.0.0-alpha.4 → 1.0.0-alpha.6
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akita-protocol/algomd-rn",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"types": "src/index.ts",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@akita-protocol/sdk": ">=1.
|
|
14
|
+
"@akita-protocol/sdk": ">=1.5.0-canary.0",
|
|
15
15
|
"@akita-protocol/txn-graph-rn": ">=0.2.1",
|
|
16
|
-
"@algorandfoundation/algokit-utils": "
|
|
16
|
+
"@algorandfoundation/algokit-utils": "^9.2.2",
|
|
17
17
|
"@gorhom/bottom-sheet": ">=5.0.0",
|
|
18
18
|
"@shopify/flash-list": ">=2.0.0",
|
|
19
19
|
"@tanstack/react-query": ">=5",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@akita-protocol/sdk": "1.
|
|
43
|
-
"@algorandfoundation/algokit-utils": "
|
|
42
|
+
"@akita-protocol/sdk": "1.5.0-canary.0",
|
|
43
|
+
"@algorandfoundation/algokit-utils": "^9.2.2",
|
|
44
44
|
"@gorhom/bottom-sheet": "^5.2.14",
|
|
45
45
|
"@playwright/test": "^1.63.0",
|
|
46
46
|
"@storybook/addon-a11y": "10.6.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/pixelmatch": "^7.1.0",
|
|
53
53
|
"@types/pngjs": "^6.0.5",
|
|
54
54
|
"@types/react": "^19.1.0",
|
|
55
|
-
"algosdk": "^3.
|
|
55
|
+
"algosdk": "^3.7.0",
|
|
56
56
|
"autoprefixer": "^10.5.6",
|
|
57
57
|
"buffer": "^6.0.3",
|
|
58
58
|
"esbuild": "^0.25.12",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"vite": "^6.4.3"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@akita-protocol/algomd-core": "1.0.0-alpha.
|
|
82
|
+
"@akita-protocol/algomd-core": "1.0.0-alpha.6"
|
|
83
83
|
},
|
|
84
84
|
"exports": {
|
|
85
85
|
".": "./src/index.ts",
|
|
@@ -56,8 +56,9 @@ async function fetchASAForGraph(
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
try {
|
|
59
|
-
const info = await algorand.client.algod.
|
|
59
|
+
const info = await algorand.client.algod.getAssetByID(BigInt(assetId)).do();
|
|
60
60
|
const p = info.params;
|
|
61
|
+
if (!p) throw new Error(`Asset ${assetId} has no params`);
|
|
61
62
|
return {
|
|
62
63
|
id: Number(assetId),
|
|
63
64
|
name: p.name ?? `Asset #${assetId}`,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
type DecodedStakingPoolReward,
|
|
39
39
|
} from "../utils/stakingPool";
|
|
40
40
|
import type { AlgorandClient } from "@algorandfoundation/algokit-utils";
|
|
41
|
-
import { getApplicationAddress } from "
|
|
41
|
+
import { getApplicationAddress } from "algosdk";
|
|
42
42
|
import type {
|
|
43
43
|
AlgorandAccount,
|
|
44
44
|
ASA as ASAType,
|
|
@@ -124,8 +124,9 @@ async function fetchASADetails(
|
|
|
124
124
|
// Asset precision is transaction-critical. Let the owning query surface a
|
|
125
125
|
// lookup error instead of fabricating a zero-decimal ASA that could turn a
|
|
126
126
|
// human amount into the wrong number of base units.
|
|
127
|
-
const info = await algorand.client.algod.
|
|
127
|
+
const info = await algorand.client.algod.getAssetByID(BigInt(assetId)).do();
|
|
128
128
|
const params = info.params;
|
|
129
|
+
if (!params) throw new Error(`Asset ${assetId} has no params`);
|
|
129
130
|
return {
|
|
130
131
|
id: Number(assetId),
|
|
131
132
|
name: params.name ?? `Asset #${assetId}`,
|
|
@@ -287,7 +288,7 @@ async function fetchPrizeBoxBundle(
|
|
|
287
288
|
const fallback: PrizeBoxBundle = { appId, address, holdings: [] };
|
|
288
289
|
|
|
289
290
|
try {
|
|
290
|
-
const info = await algorand.client.algod.accountInformation(address);
|
|
291
|
+
const info = await algorand.client.algod.accountInformation(address).do();
|
|
291
292
|
const assetBalances = (info.assets ?? []).filter(
|
|
292
293
|
(holding: { amount: bigint }) => holding.amount > BigInt(0),
|
|
293
294
|
);
|
|
@@ -358,7 +359,7 @@ export function useAccountData(address: string | undefined) {
|
|
|
358
359
|
queryKey: ["algomd", config.network, "account", address],
|
|
359
360
|
queryFn: async (): Promise<AlgorandAccount> => {
|
|
360
361
|
if (!address) throw new Error("No address provided");
|
|
361
|
-
const info = await algorand.client.algod.accountInformation(address);
|
|
362
|
+
const info = await algorand.client.algod.accountInformation(address).do();
|
|
362
363
|
const assets: ASAType[] = (info.assets ?? []).map(
|
|
363
364
|
(a: { assetId: bigint; amount: bigint }) => ({
|
|
364
365
|
id: Number(a.assetId),
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react'
|
|
2
2
|
import { AlgorandClient } from '@algorandfoundation/algokit-utils'
|
|
3
|
-
import { AlgodClient } from '@algorandfoundation/algokit-utils/algod-client'
|
|
4
3
|
import algosdk from 'algosdk'
|
|
5
|
-
import { makeEmptyTransactionSigner } from '@algorandfoundation/algokit-utils/transact'
|
|
6
4
|
import { useAlgomd } from '../provider/context'
|
|
7
5
|
import { NETWORK_DEFAULTS } from '../provider/networks'
|
|
8
6
|
|
|
@@ -21,17 +19,12 @@ export function useAlgorandClient(): AlgorandClient {
|
|
|
21
19
|
const token = config.algodToken ?? defaults.algodToken ?? ''
|
|
22
20
|
|
|
23
21
|
const client = AlgorandClient.fromClients({
|
|
24
|
-
algod: new
|
|
25
|
-
baseUrl: server,
|
|
26
|
-
port,
|
|
27
|
-
token,
|
|
28
|
-
headers: config.headers,
|
|
29
|
-
}),
|
|
22
|
+
algod: new algosdk.Algodv2(token, server, port, config.headers),
|
|
30
23
|
})
|
|
31
24
|
|
|
32
25
|
// Register an empty signer so explicitly simulated read methods can run
|
|
33
26
|
// without a real signer. This is safe — algomd-rn is a display library.
|
|
34
|
-
client.setDefaultSigner(makeEmptyTransactionSigner())
|
|
27
|
+
client.setDefaultSigner(algosdk.makeEmptyTransactionSigner())
|
|
35
28
|
|
|
36
29
|
return client
|
|
37
30
|
}, [config.network, config.algodServer, config.algodPort, config.algodToken, config.headers])
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
EllipsisVerticalIcon,
|
|
10
10
|
ArrowTopRightOnSquareIcon,
|
|
11
11
|
Square2StackIcon,
|
|
12
|
+
OutlineDocumentTextIcon,
|
|
12
13
|
} from "./icons";
|
|
13
14
|
import * as Clipboard from "expo-clipboard";
|
|
14
15
|
import * as Haptics from "expo-haptics";
|
|
@@ -60,6 +61,39 @@ const LABELS: Record<EntityType, string> = {
|
|
|
60
61
|
tx: "Transaction",
|
|
61
62
|
};
|
|
62
63
|
|
|
64
|
+
/** The AlgoMD tag Copy Embed copies and Quote starts a post with, or undefined when there is none. */
|
|
65
|
+
export function buildEmbed({
|
|
66
|
+
appId,
|
|
67
|
+
type = "application",
|
|
68
|
+
embedType,
|
|
69
|
+
embedProp,
|
|
70
|
+
embedValue,
|
|
71
|
+
}: Pick<ContractMenuProps, "appId" | "type" | "embedType" | "embedProp" | "embedValue">): string | undefined {
|
|
72
|
+
const componentName =
|
|
73
|
+
embedType ??
|
|
74
|
+
(type === "asset"
|
|
75
|
+
? "ASA"
|
|
76
|
+
: type === "account"
|
|
77
|
+
? "Account"
|
|
78
|
+
: type === "tx"
|
|
79
|
+
? "Transaction"
|
|
80
|
+
: undefined);
|
|
81
|
+
if (!componentName) return undefined;
|
|
82
|
+
|
|
83
|
+
const idProp =
|
|
84
|
+
embedProp ??
|
|
85
|
+
(componentName === "NFDProfile"
|
|
86
|
+
? "name"
|
|
87
|
+
: componentName === "DualStakePool"
|
|
88
|
+
? "appId"
|
|
89
|
+
: type === "account"
|
|
90
|
+
? "address"
|
|
91
|
+
: "id");
|
|
92
|
+
const value = embedValue ?? appId;
|
|
93
|
+
const compactProp = componentName === "Account" ? " compact" : "";
|
|
94
|
+
return `<${componentName} ${idProp}="${String(value)}"${compactProp} />`;
|
|
95
|
+
}
|
|
96
|
+
|
|
63
97
|
export function ContractMenu({
|
|
64
98
|
appId,
|
|
65
99
|
type = "application",
|
|
@@ -94,40 +128,25 @@ export function ContractMenu({
|
|
|
94
128
|
sheetRef.current?.dismiss();
|
|
95
129
|
}, [appId]);
|
|
96
130
|
|
|
131
|
+
const embed = buildEmbed({ appId, type, embedType, embedProp, embedValue });
|
|
132
|
+
|
|
97
133
|
const handleCopyEmbed = useCallback(() => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
(type === "asset"
|
|
101
|
-
? "ASA"
|
|
102
|
-
: type === "account"
|
|
103
|
-
? "Account"
|
|
104
|
-
: type === "tx"
|
|
105
|
-
? "Transaction"
|
|
106
|
-
: undefined);
|
|
107
|
-
if (!componentName) return;
|
|
108
|
-
|
|
109
|
-
const idProp =
|
|
110
|
-
embedProp ??
|
|
111
|
-
(componentName === "NFDProfile"
|
|
112
|
-
? "name"
|
|
113
|
-
: componentName === "DualStakePool"
|
|
114
|
-
? "appId"
|
|
115
|
-
: type === "account"
|
|
116
|
-
? "address"
|
|
117
|
-
: "id");
|
|
118
|
-
const value = embedValue ?? appId;
|
|
119
|
-
|
|
120
|
-
const compactProp = componentName === "Account" ? " compact" : "";
|
|
121
|
-
Clipboard.setStringAsync(
|
|
122
|
-
`<${componentName} ${idProp}="${String(value)}"${compactProp} />`,
|
|
123
|
-
);
|
|
134
|
+
if (!embed) return;
|
|
135
|
+
Clipboard.setStringAsync(embed);
|
|
124
136
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
|
125
137
|
sheetRef.current?.dismiss();
|
|
126
|
-
}, [
|
|
138
|
+
}, [embed]);
|
|
139
|
+
|
|
140
|
+
const { onQuoteEmbed } = presentation;
|
|
141
|
+
const handleQuote = useCallback(() => {
|
|
142
|
+
if (!embed || !onQuoteEmbed) return;
|
|
143
|
+
Haptics.selectionAsync();
|
|
144
|
+
sheetRef.current?.dismiss();
|
|
145
|
+
onQuoteEmbed(embed);
|
|
146
|
+
}, [embed, onQuoteEmbed]);
|
|
127
147
|
|
|
128
148
|
const label = LABELS[type];
|
|
129
|
-
const canCopyEmbed =
|
|
130
|
-
!!embedType || type === "asset" || type === "account" || type === "tx";
|
|
149
|
+
const canCopyEmbed = !!embed;
|
|
131
150
|
|
|
132
151
|
return (
|
|
133
152
|
<>
|
|
@@ -234,6 +253,26 @@ export function ContractMenu({
|
|
|
234
253
|
</View>
|
|
235
254
|
</SquishyPressable>
|
|
236
255
|
)}
|
|
256
|
+
|
|
257
|
+
{canCopyEmbed && onQuoteEmbed && (
|
|
258
|
+
<SquishyPressable onPress={handleQuote} pressedScale={0.98}>
|
|
259
|
+
<View
|
|
260
|
+
style={{
|
|
261
|
+
flexDirection: "row",
|
|
262
|
+
alignItems: "center",
|
|
263
|
+
gap: 12,
|
|
264
|
+
paddingVertical: 14,
|
|
265
|
+
paddingHorizontal: 8,
|
|
266
|
+
borderRadius: 12,
|
|
267
|
+
}}
|
|
268
|
+
>
|
|
269
|
+
<OutlineDocumentTextIcon size={18} color={theme.colors.text} />
|
|
270
|
+
<Text size="sm" weight="medium">
|
|
271
|
+
Quote
|
|
272
|
+
</Text>
|
|
273
|
+
</View>
|
|
274
|
+
</SquishyPressable>
|
|
275
|
+
)}
|
|
237
276
|
</BottomSheetView>
|
|
238
277
|
</AppPresentationProvider>
|
|
239
278
|
</PortalProvider>
|
|
@@ -109,6 +109,11 @@ export interface AppPresentation {
|
|
|
109
109
|
*/
|
|
110
110
|
applicationIcon?: (appId: string) => { Icon: React.ComponentType<{ size?: number; color?: string }>; color?: string } | undefined;
|
|
111
111
|
onOpenNfd?: (name: string) => void;
|
|
112
|
+
/**
|
|
113
|
+
* Starts a new post that quotes an embed (e.g. `<ASA id="31566704" />`). Menus that offer
|
|
114
|
+
* Copy Embed also offer Quote when the host provides this.
|
|
115
|
+
*/
|
|
116
|
+
onQuoteEmbed?: (embed: string) => void;
|
|
112
117
|
onOpenCollection?: (id: string) => void;
|
|
113
118
|
onOpenTransaction?: (txId: string) => void;
|
|
114
119
|
/** Opens a contract reference (listing, auction, raffle, poll) in the host. */
|