@audius/sdk 3.0.8-beta.7 → 3.0.8-beta.9

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,8 +1,8 @@
1
1
  {
2
2
  "name": "@audius/sdk",
3
- "version": "3.0.8-beta.7",
3
+ "version": "3.0.8-beta.9",
4
4
  "audius": {
5
- "releaseSHA": "72c223f61d61e353356d3b0f33e8db6a17e5b7a9"
5
+ "releaseSHA": "460ca8bcef335cf7cfed191d2d26f1f913b2eee2"
6
6
  },
7
7
  "description": "Audius SDK",
8
8
  "keywords": [
@@ -398,9 +398,11 @@ export class IdentityService {
398
398
  gasLimit: number,
399
399
  handle: string | null = null,
400
400
  nethermindContractAddress: string | null | undefined,
401
- nethermindEncodedAbi: string | undefined
401
+ nethermindEncodedAbi: string | undefined,
402
+ baseURL?: string
402
403
  ): Promise<{ receipt: TransactionReceipt }> {
403
404
  return await this._makeRequest({
405
+ baseURL,
404
406
  url: '/relay',
405
407
  method: 'post',
406
408
  data: {
@@ -601,7 +603,7 @@ export class IdentityService {
601
603
  /* ------- INTERNAL FUNCTIONS ------- */
602
604
 
603
605
  async _makeRequest<T = unknown>(axiosRequestObj: AxiosRequestConfig) {
604
- axiosRequestObj.baseURL = this.identityServiceEndpoint
606
+ axiosRequestObj.baseURL = axiosRequestObj.baseURL || this.identityServiceEndpoint
605
607
 
606
608
  const requestId = uuid()
607
609
  axiosRequestObj.headers = {
@@ -207,7 +207,23 @@ export class TransactionHandler {
207
207
  })
208
208
  }
209
209
 
210
- const rawTransaction = tx.serialize()
210
+ let rawTransaction: Buffer
211
+ try {
212
+ rawTransaction = tx.serialize()
213
+ } catch (e) {
214
+ logger.warn(`transactionHandler: transaction serialization failed: ${e}`)
215
+ let errorCode = null
216
+ let error = null
217
+ if (e instanceof Error) {
218
+ error = e.message
219
+ errorCode = this._parseSolanaErrorCode(error)
220
+ }
221
+ return {
222
+ res: null,
223
+ error,
224
+ errorCode
225
+ }
226
+ }
211
227
 
212
228
  // Send the txn
213
229
 
@@ -243,34 +243,19 @@ export class Web3Manager {
243
243
  const response = await retry(
244
244
  async (bail) => {
245
245
  try {
246
- if (this.useDiscoveryRelay()) {
247
- // use discovery relay
248
- const res = await this.discoveryProvider?.relay({
249
- contractRegistryKey,
250
- contractAddress,
251
- senderAddress: this.ownerWallet!.getAddressString(),
252
- encodedABI,
253
- gasLimit,
254
- handle: this.userSuppliedHandle,
255
- nethermindContractAddress,
256
- nethermindEncodedAbi
257
- })
258
- if (res === null || res === undefined) {
259
- throw new Error("discovery relay returned empty response")
260
- }
261
- return res
262
- } else {
263
- return await this.identityService?.relay(
264
- contractRegistryKey,
265
- contractAddress,
266
- this.ownerWallet!.getAddressString(),
267
- encodedABI,
268
- gasLimit,
269
- this.userSuppliedHandle,
270
- nethermindContractAddress,
271
- nethermindEncodedAbi
272
- )
273
- }
246
+ const baseURL = this.useDiscoveryRelay() ? this.discoveryProvider?.discoveryProviderEndpoint : this.identityService?.identityServiceEndpoint
247
+ console.error(`relaying to base url ${baseURL}`)
248
+ return await this.identityService?.relay(
249
+ contractRegistryKey,
250
+ contractAddress,
251
+ this.ownerWallet!.getAddressString(),
252
+ encodedABI,
253
+ gasLimit,
254
+ this.userSuppliedHandle,
255
+ nethermindContractAddress,
256
+ nethermindEncodedAbi,
257
+ baseURL
258
+ )
274
259
  } catch (e: any) {
275
260
  // If forbidden, don't retry
276
261
  if (e.response.status === 403) {