Skip to content

Commit e2d91d4

Browse files
authored
Merge pull request #812 from TokenScript/staging
Staging
2 parents 29cae27 + 9b6aeac commit e2d91d4

File tree

9 files changed

+45
-33
lines changed

9 files changed

+45
-33
lines changed

CHANGELOG.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
> Description
22
3-
This major version of the Token Negotiator provides simplification to the library interface, and new core features including multi-attestation support.
3+
Patch release to support the upgrade of attestations.
44

55
### Upgrade Steps
66

7-
- Please refer to the migration from 2x to 3x guide. https://tokenscript.gitbook.io/token-negotiator/migrating-from-version-2x-to-3x
7+
- Update NPM package to version 3.0.1
88

99
### Breaking Changes
1010

11-
- Passive Negotiation 'tokens' hook
12-
- Off chain interface changes
13-
- off chain Attestation schema changes (ASN / EAS)
11+
[none]
1412

1513
### New Features
1614

17-
- Support for multi batch EAS & ASN attestation readability and authentication
18-
- Dynamic EAS attestation support
19-
- AlphaWallet provider selection in active UI mode
20-
- Ultra Network support (BETA)
21-
- Removal of Wallet Connect V1
22-
- Migrated this libraries documentation from README to gitbooks https://tokenscript.gitbook.io/token-negotiator/
23-
- Added attestation migration support utility function 'migrateLegacyTokenStorage'
15+
- Ability to delete existing attestations
2416

2517
### Bug Fixes
2618

27-
- MetaMask support via Wallet Connect V2
28-
- attestation.id modal dimensions updated for mobile and via Windows browsers
19+
- Added support for upgrading attestations for live projects (method added via TicketStorage deleteTicketByDecodedTokenOrId)
2920

3021
### Performance Improvements
3122

32-
- Simplified off chain storage of issuer data
23+
[none]
3324

3425
**Full Change log**:
3526

36-
https://github.com/TokenScript/token-negotiator/compare/v2.7.1...v3.0.0
27+
https://github.com/TokenScript/token-negotiator/compare/v3.0.0...v3.0.1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tokenscript/token-negotiator",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "Token-negotiator a token attestation bridge between web 2.0 and 3.0.",
55
"module": "dist/index.js",
66
"types": "dist/index.d.ts",

src/client/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ export class Client {
10941094
) {
10951095
requiredParams(type, 'Event type is not defined')
10961096

1097-
if ((type === 'tokens' || type === 'tokens-selected') && callback) {
1097+
if (type === 'tokens-selected' && callback) {
10981098
this.readTokensFromUrl()
10991099
}
11001100

src/client/interface.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { BrowserDataInterface } from '../utils/support/isSupported'
55
import { WalletConnection } from '../wallet/Web3WalletProvider'
66
import { DecodedToken } from '../outlet/ticketStorage'
77
import { EasSchemaConfig } from '../outlet/interfaces'
8+
import { TokenData } from './tokenStore'
89

910
export type SupportedBlockchainsParam = 'evm' | 'flow' | 'solana' | 'ultra'
1011
export const SignatureSupportedBlockchainsParamList = ['evm', 'flow', 'solana', 'ultra']
@@ -117,7 +118,6 @@ export interface TokenNegotiatorEventsArgs {
117118
'connected-wallet': EventSenderConnectedWallet
118119
'disconnected-wallet': EventSenderDisconnectedWallet
119120
'tokens-selected': EventSenderTokensSelected
120-
tokens: EventSenderTokens
121121
'tokens-loaded': EventSenderTokensLoaded
122122
'network-change': string
123123
error: EventSenderError
@@ -150,11 +150,11 @@ export interface EventSenderViewChanged {
150150
}
151151

152152
export interface EventSenderTokensSelected {
153-
selectedTokens: Object
154-
}
155-
156-
export interface EventSenderTokens {
157-
data: any[]
153+
selectedTokens: {
154+
[collectionId: string]: {
155+
tokens: DecodedToken[] | TokenData[]
156+
}
157+
}
158158
}
159159

160160
export interface EventSenderTokensLoaded {

src/client/tokenStore.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { OffChainTokenConfig, OnChainIssuer, OnChainTokenConfig, SolanaIssuerConfig, UltraIssuerConfig } from './interface'
22

33
import { logger } from '../utils'
4+
import { DecodedToken } from '../outlet/ticketStorage'
45

56
interface IssuerLookup {
67
[collectionID: string]: TokenConfig & { timestamp: number }
@@ -10,14 +11,17 @@ interface TokenLookup {
1011
[issuer: string]: { timestamp: number; tokens: TokenData[] | null }
1112
}
1213

13-
interface TokenData {
14+
export interface TokenData {
15+
tokenId: string | number
1416
walletAddress?: string
1517
// TODO: add more common fields to this interface
1618
[key: string]: any
1719
}
1820

1921
type TokenConfig = OnChainTokenConfig | OffChainTokenConfig | SolanaIssuerConfig | UltraIssuerConfig
2022

23+
type SelectedTokens = { [collectionId: string]: { tokens: DecodedToken[] | TokenData[] } }
24+
2125
export class TokenStore {
2226
public static LOCAL_STORAGE_KEY = 'tn-tokenStore'
2327

@@ -28,7 +32,7 @@ export class TokenStore {
2832
private tokenLookup: IssuerLookup = {}
2933

3034
// TODO: change to disabled tokens
31-
private selectedTokens: any = {}
35+
private selectedTokens: SelectedTokens = {}
3236

3337
constructor(
3438
private autoEnableTokens: boolean,
@@ -173,7 +177,7 @@ export class TokenStore {
173177
return null
174178
}
175179

176-
public setTokens(issuer: string, tokens: TokenData[]) {
180+
public setTokens(issuer: string, tokens: TokenData[] | DecodedToken[]) {
177181
this.tokenData[issuer] = { timestamp: Date.now(), tokens }
178182

179183
this.saveTokenStore()
@@ -185,7 +189,7 @@ export class TokenStore {
185189
return this.selectedTokens
186190
}
187191

188-
public setSelectedTokens(selectedTokens: any) {
192+
public setSelectedTokens(selectedTokens: SelectedTokens) {
189193
this.selectedTokens = selectedTokens
190194
}
191195

src/client/views/token-list.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ export class TokenList extends AbstractView {
110110

111111
this.viewContainer.querySelectorAll('.mobileToggle-tn').forEach((token: any, index: number) => {
112112
if (index === 0) {
113-
selectedTokens[token.dataset.key] = {}
114-
selectedTokens[token.dataset.key]['tokens'] = []
113+
selectedTokens[token.dataset.key] = { tokens: [] }
115114
}
116115

117116
if (token.checked === true) {

src/outlet/localOutlet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { MultiTokenAuthRequest, MultiTokenAuthResult, OutletInterface, OutletIss
66
import { OutletAction } from '../client/messaging'
77

88
export class LocalOutlet {
9-
protected ticketStorage: TicketStorage
9+
public readonly ticketStorage: TicketStorage
1010

1111
constructor(config: OutletInterface) {
1212
this.ticketStorage = new TicketStorage(config)

src/outlet/ticketStorage.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface EasFieldData {
7171
}
7272

7373
interface TicketStorageSchema {
74-
[collectionHash: string]: StoredTicketRecord[]
74+
[collectionHash: string]: Array<StoredTicketRecord>
7575
}
7676

7777
export interface FilterInterface {
@@ -167,6 +167,24 @@ export class TicketStorage {
167167
})
168168
}
169169

170+
public deleteTicketByDecodedTokenOrId(collectionId: string, decodedTokenOrId: DecodedToken | string) {
171+
const config = this.config.issuers.find((issuer) => issuer.collectionID === collectionId)
172+
const hashes = createIssuerHashArray(config)
173+
const tokenId = typeof decodedTokenOrId === 'string' ? decodedTokenOrId : decodedTokenOrId.tokenId
174+
175+
for (const hash of hashes) {
176+
for (let i = 0; i < this.ticketCollections[hash].length; i++) {
177+
if (tokenId === this.ticketCollections[hash][0].tokenId) {
178+
this.ticketCollections[hash].splice(i, 1)
179+
this.storeTickets()
180+
return true
181+
}
182+
}
183+
}
184+
185+
return false
186+
}
187+
170188
/**
171189
* Take in a request of collection hashes and return the returns, keyed by client provided ID
172190
* @param request

src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// modified by build process.
2-
export const VERSION = '3.0.0'
2+
export const VERSION = '3.0.1'

0 commit comments

Comments
 (0)