Skip to content

Commit c1bac75

Browse files
committed
add prepack command for direct consumption in yarn monorepos.
1 parent 376f171 commit c1bac75

File tree

5 files changed

+2801
-65
lines changed

5 files changed

+2801
-65
lines changed

bun.lockb

-167 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"url": "https://github.com/dialectlabs/blinks"
1111
},
1212
"scripts": {
13-
"build": "tsup-node"
13+
"build": "tsup-node",
14+
"prepack": "tsup-node"
1415
},
1516
"main": "dist/index.cjs",
1617
"module": "dist/index.js",

src/api/ActionConfig.ts

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Connection } from '@solana/web3.js';
21
import { ActionComponent, type Action } from './Action.ts';
32

43
export interface ActionContext {
@@ -30,66 +29,3 @@ export interface ActionAdapter {
3029
context: ActionContext,
3130
) => Promise<void>;
3231
}
33-
34-
export class ActionConfig implements ActionAdapter {
35-
private static readonly CONFIRM_TIMEOUT_MS = 60000 * 1.2; // 20% extra time
36-
private connection: Connection;
37-
38-
constructor(
39-
rpcUrl: string,
40-
private adapter: IncomingActionConfig['adapter'],
41-
) {
42-
if (!rpcUrl) {
43-
throw new Error('rpcUrl is required');
44-
}
45-
46-
this.connection = new Connection(rpcUrl, 'confirmed');
47-
}
48-
49-
async connect(context: ActionContext) {
50-
try {
51-
return await this.adapter.connect(context);
52-
} catch {
53-
return null;
54-
}
55-
}
56-
57-
signTransaction(tx: string, context: ActionContext) {
58-
return this.adapter.signTransaction(tx, context);
59-
}
60-
61-
confirmTransaction(signature: string): Promise<void> {
62-
return new Promise<void>((res, rej) => {
63-
const start = Date.now();
64-
65-
const confirm = async () => {
66-
if (Date.now() - start >= ActionConfig.CONFIRM_TIMEOUT_MS) {
67-
rej(new Error('Unable to confirm transaction'));
68-
return;
69-
}
70-
71-
try {
72-
const status = await this.connection.getSignatureStatus(signature);
73-
74-
// if error present, transaction failed
75-
if (status.value?.err) {
76-
rej(new Error('Transaction execution failed'));
77-
return;
78-
}
79-
80-
// if has confirmations, transaction is successful
81-
if (status.value && status.value.confirmations !== null) {
82-
res();
83-
return;
84-
}
85-
} catch (e) {
86-
console.error('Error confirming transaction', e);
87-
}
88-
89-
setTimeout(confirm, 3000);
90-
};
91-
92-
confirm();
93-
});
94-
}
95-
}

src/ui/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "ui",
3+
"version": "1.0.0",
4+
"dependencies": {
5+
}
6+
}

0 commit comments

Comments
 (0)