Skip to content

Commit e79b150

Browse files
dmarzzzlnbc1QWFyb24Adamj1232freeatnetjulianapeace
authored
Release 4.3.0 [master] (#189)
* 4.0.0-0.1.0 : Add fantom network #173 * Add fantom network (fantom-main) to Network type in interfaces.ts and networks object in defaults.ts * Update version * 4.0.0-0.1.1 - Test whether localStorage is accessible before performing operations (#172) * 4.1.0 Release - Develop (#175) * Update version * Add gasGwei values * Feature/ws simulate (#178) 4.1.0-0.1.0: Handles websocket simulation requests * DEVELOP - Release/4.2.0 (#180) 4.2.0 Release * 4.2.0-0.1.0 [Feature] Error Handling for UNSUPPORTED_CHAIN_MSG (#186) * 4.2.0-0.1.0 [ feature ] : Mumbai testnet support (#185) * add support for matic-mumbai * add support for matic-mumbai * add support for matic-mumbai * v4.3.0 * Bump ajv from 6.12.2 to 6.12.6 (#182) Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.12.2 to 6.12.6. - [Release notes](https://github.com/ajv-validator/ajv/releases) - [Commits](ajv-validator/ajv@v6.12.2...v6.12.6) --- updated-dependencies: - dependency-name: ajv dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump minimist from 1.2.5 to 1.2.6 (#179) Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Create issue-to-notion.yml (#177) * 4.1.0 Release - Master (#174) * 4.0.0-0.1.0 : Add fantom network #173 * Add fantom network (fantom-main) to Network type in interfaces.ts and networks object in defaults.ts * Update version * 4.0.0-0.1.1 - Test whether localStorage is accessible before performing operations (#172) * Update version * Add gasGwei values Co-authored-by: Aaron Barnard <abarnard@protonmail.com> Co-authored-by: Arseniy Ivanov <138289+freeatnet@users.noreply.github.com> * Create issue-to-notion.yml Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com> Co-authored-by: Aaron Barnard <abarnard@protonmail.com> Co-authored-by: Arseniy Ivanov <138289+freeatnet@users.noreply.github.com> * 4.2.0-0.2.0: [enhancement] - Expose Watched Items (#191) * Expose watchedItems * Increment version * Fix eventCode error Co-authored-by: Aaron Barnard <abarnard@protonmail.com> Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com> Co-authored-by: Arseniy Ivanov <138289+freeatnet@users.noreply.github.com> Co-authored-by: Julie <julianapeace@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Taylor Dawson <taylorjdawson@gmail.com>
1 parent 4499d2f commit e79b150

File tree

12 files changed

+209
-111
lines changed

12 files changed

+209
-111
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Github issue -> Notion card
2+
on:
3+
workflow_dispatch:
4+
issues:
5+
types: [opened]
6+
jobs:
7+
issue:
8+
name: "Issue to Notion"
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- run: |
13+
people=$(for i in $(echo $NOTION_USER_IDS | tr "," " "); do echo -n '{"object":"user","id":"'$i'"},'; done)
14+
curl 'https://api.notion.com/v1/pages' \
15+
-H 'Authorization: Bearer '"$NOTION_TOKEN"'' \
16+
-H "Content-Type: application/json" \
17+
-H "Notion-Version: 2022-02-22" \
18+
--data '{"parent":{"type":"database_id","database_id":"'"$DATABASE_ID"'"},"icon":{"type":"emoji","emoji":"🐛"},"properties":{"Name":{"type":"title","title":[{"type":"text","text":{"content":"'"$TITLE"'"}}]},"Assigned":{"people":['${people:0:-1}']},"Status":{"select":{"name":"'"$STATUS"'"}},"Type":{"multi_select":[{"name":"bug"}]},"Project":{"multi_select":[{"name":"'"$PROJECT_NAME"'"}]}},"children":[{"object":"block","type":"bookmark","bookmark":{"url":"'"$ISSUE_URL"'"}}]}'
19+
env:
20+
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
21+
STATE: ${{ github.event.issue.state }}
22+
ISSUE_URL: ${{ github.event.issue.html_url }}
23+
TITLE: ${{ github.event.issue.title }}
24+
STATUS: Current Sprint
25+
# Product Work Board
26+
DATABASE_ID: 29876f9a9b864ca39a984f42e17fd345
27+
PROJECT_NAME: SDK
28+
# User ids of who to assign the card to in notion: Taylor, Adam, Aaron
29+
NOTION_USER_IDS: f6cbb362-4908-4138-9ef0-434003d9a9f8,8a3a2287-5d2c-4665-906d-02ae9a113340,3b407adf-6552-40de-b22f-5efa852c34a2
30+
shell: bash

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-sdk",
3-
"version": "4.2.0",
3+
"version": "4.3.0",
44
"description": "SDK to connect to the blocknative backend via a websocket connection",
55
"keywords": [
66
"ethereum",

src/account.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { createEmitter } from './utilities'
22
import { Emitter, Ac } from './interfaces'
3+
import Blocknative from '.'
34

45
function account(
5-
this: any,
6+
this: Blocknative,
67
address: string
78
): { emitter: Emitter; details: { address: string } } {
89
if (this._destroyed)
@@ -19,7 +20,7 @@ function account(
1920
// create eventCode for transaction
2021
const eventCode = 'watch'
2122

22-
const existingAddressWatcher = this._watchedAccounts.find(
23+
const existingAddressWatcher = this.watchedAccounts.find(
2324
(ac: Ac) => ac.address === address
2425
)
2526

@@ -28,7 +29,7 @@ function account(
2829
existingAddressWatcher.emitters.push(emitter)
2930
} else {
3031
// put in accounts queue
31-
this._watchedAccounts.push({
32+
this.watchedAccounts.push({
3233
address,
3334
emitters: [emitter]
3435
})

src/configuration.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Subject } from 'rxjs'
22
import { take, timeout } from 'rxjs/operators'
3+
import Blocknative from '.'
34
import { Config, Emitter } from './interfaces'
45
import { createEmitter } from './utilities'
56

67
function configuration(
7-
this: any,
8+
this: Blocknative,
89
config: Config
910
): Promise<string | { details: { config: Config }; emitter?: Emitter }> {
1011
if (this._destroyed) {
@@ -17,18 +18,18 @@ function configuration(
1718
this._system === 'ethereum' ? config.scope.toLowerCase() : config.scope
1819

1920
// resolve previous configuration if exists
20-
const previousConfiguration = this._configurations.get(casedScope)
21+
const previousConfiguration = this.configurations.get(casedScope)
2122

2223
previousConfiguration &&
2324
previousConfiguration.subscription &&
2425
previousConfiguration.subscription.next()
2526

26-
const subscription = new Subject()
27+
const subscription = new Subject<string>()
2728

2829
// create emitter for transaction
2930
const emitter = config.watchAddress ? { emitter: createEmitter() } : {}
3031

31-
this._configurations.set(casedScope, {
32+
this.configurations.set(casedScope, {
3233
...config,
3334
...emitter,
3435
subscription

src/defaults.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export const networks: { [key: string]: { [key: string]: string } } = {
1212
'56': 'bsc-main',
1313
'100': 'xdai',
1414
'137': 'matic-main',
15-
'250': 'fantom-main'
15+
'250': 'fantom-main',
16+
'80001': 'matic-mumbai'
1617
}
1718
}
1819

src/index.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,26 @@ const DEFAULT_APP_VERSION = 'unknown'
4141
const DEFAULT_SYSTEM = 'ethereum'
4242

4343
class Blocknative {
44-
private _storageKey: string
45-
private _connectionId: string | undefined
46-
private _dappId: string
47-
private _system: string
48-
private _networkId: number
49-
private _appName: string
50-
private _appVersion: string
51-
private _transactionHandlers: TransactionHandler[]
52-
private _socket: any
53-
private _connected: boolean
54-
private _sendMessage: (msg: EventObject) => void
55-
private _watchedTransactions: Tx[]
56-
private _watchedAccounts: Ac[]
57-
private _configurations: Map<string, EnhancedConfig>
58-
private _pingTimeout?: NodeJS.Timeout
59-
private _heartbeat?: () => void
60-
private _destroyed: boolean
61-
private _onerror: ((error: SDKError) => void) | undefined
62-
private _queuedMessages: EventObject[]
63-
private _limitRules: LimitRules
64-
private _waitToRetry: null | Promise<void>
65-
private _processingQueue: boolean
66-
private _processQueue: () => Promise<void>
44+
protected _storageKey: string
45+
protected _connectionId: string | undefined
46+
protected _dappId: string
47+
protected _system: string
48+
protected _networkId: number
49+
protected _appName: string
50+
protected _appVersion: string
51+
protected _transactionHandlers: TransactionHandler[]
52+
protected _socket: any
53+
protected _connected: boolean
54+
protected _sendMessage: (msg: EventObject) => void
55+
protected _pingTimeout?: NodeJS.Timeout
56+
protected _heartbeat?: () => void
57+
protected _destroyed: boolean
58+
protected _onerror: ((error: SDKError) => void) | undefined
59+
protected _queuedMessages: EventObject[]
60+
protected _limitRules: LimitRules
61+
protected _waitToRetry: null | Promise<void>
62+
protected _processingQueue: boolean
63+
protected _processQueue: () => Promise<void>
6764

6865
public transaction: Transaction
6966
public account: Account
@@ -72,6 +69,9 @@ class Blocknative {
7269
public unsubscribe: Unsubscribe
7370
public destroy: Destroy
7471
public configuration: Configuration
72+
public watchedTransactions: Tx[]
73+
public watchedAccounts: Ac[]
74+
public configurations: Map<string, EnhancedConfig>
7575

7676
constructor(options: InitializationOptions) {
7777
validateOptions(options)
@@ -131,9 +131,6 @@ class Blocknative {
131131
this._socket = socket
132132
this._connected = false
133133
this._sendMessage = sendMessage.bind(this)
134-
this._watchedTransactions = []
135-
this._watchedAccounts = []
136-
this._configurations = new Map()
137134
this._pingTimeout = undefined
138135
this._destroyed = false
139136
this._onerror = onerror
@@ -160,6 +157,9 @@ class Blocknative {
160157
}
161158

162159
// public API
160+
this.watchedTransactions = []
161+
this.watchedAccounts = []
162+
this.configurations = new Map()
163163
this.transaction = transaction.bind(this)
164164
this.account = account.bind(this)
165165
this.event = event.bind(this)
@@ -219,11 +219,11 @@ async function onReopen(this: any, handler: (() => void) | undefined) {
219219

220220
// re-register all configurations on re-connection
221221
const configurations: EnhancedConfig[] = Array.from(
222-
this._configurations.values()
222+
this.configurations.values()
223223
)
224224

225225
// register global config first and wait for it to complete
226-
const globalConfiguration = this._configurations.get('global')
226+
const globalConfiguration = this.configurations.get('global')
227227

228228
if (globalConfiguration) {
229229
try {
@@ -256,7 +256,7 @@ async function onReopen(this: any, handler: (() => void) | undefined) {
256256
// re-register all accounts to be watched by server upon
257257
// re-connection as they don't get transferred over automatically
258258
// to the new connection like tx hashes do
259-
this._watchedAccounts.forEach((account: Ac) => {
259+
this.watchedAccounts.forEach((account: Ac) => {
260260
this._sendMessage({
261261
eventCode: 'accountAddress',
262262
categoryCode: 'watch',

src/interfaces.ts

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export type Network =
124124
| 'bsc-main'
125125
| 'matic-main'
126126
| 'fantom-main'
127+
| 'matic-mumbai'
127128
| 'local'
128129

129130
export type Status =
@@ -276,7 +277,7 @@ export interface SimulationTransaction {
276277
to: string
277278
value: number
278279
gas: number
279-
input: string,
280+
input: string
280281
gasPrice?: number
281282
maxPriorityFeePerGas?: number
282283
maxFeePerGas?: number
@@ -311,26 +312,69 @@ export interface SimulationTransactionOutput {
311312
}
312313

313314
export interface Simulate {
314-
(system: System, network: Network, transaction: SimulationTransaction): Promise<SimulationTransactionOutput>
315+
(
316+
system: System,
317+
network: Network,
318+
transaction: SimulationTransaction
319+
): Promise<SimulationTransactionOutput>
315320
}
316321

317-
export interface EventObject {
322+
export type BaseEventObject = {
318323
eventCode: string
319324
categoryCode: string
320-
transaction?: TransactionEventLog
321-
wallet?: {
322-
balance: string
323-
}
324-
contract?: {
325+
}
326+
327+
export type BaseTransactionEventObject = {
328+
startTime?: number
329+
status?: string
330+
id?: string
331+
}
332+
333+
export type BitcoinTransactionEventObject = BaseTransactionEventObject & {
334+
txid: string
335+
}
336+
337+
export type EthereumTransactionEventObject = BaseTransactionEventObject & {
338+
hash: string
339+
}
340+
341+
export type TransactionEventObject = BaseEventObject & {
342+
transaction:
343+
| BitcoinTransactionEventObject
344+
| EthereumTransactionEventObject
345+
| SimulationTransaction
346+
}
347+
348+
export type WalletEventObject = BaseEventObject & {
349+
balance: { balance: string }
350+
}
351+
export type ContractEventObject = BaseEventObject & {
352+
contract: {
325353
methodName: string
326354
parameters: any[]
327355
}
328-
account?: {
356+
}
357+
358+
export type AccountEventObject = BaseEventObject & {
359+
account: {
329360
address: string
330361
}
331-
connectionId?: string
332362
}
333363

364+
export type InitializeEventObject = BaseEventObject & { connectionId: string }
365+
366+
export type ConfigEventObject = BaseEventObject & {
367+
config: Config
368+
}
369+
370+
export type EventObject =
371+
| TransactionEventObject
372+
| WalletEventObject
373+
| ContractEventObject
374+
| AccountEventObject
375+
| InitializeEventObject
376+
| ConfigEventObject
377+
334378
export interface TransactionHandler {
335379
(transaction: TransactionEvent): void
336380
}

0 commit comments

Comments
 (0)